• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

different JComboBoxes as editors on multiple JTable rows

 
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Objective: Use JComboBoxes within two columns of a JTable. Within each row of the table, the value of the first JComboBox will dictate what values are presented for selection within the second JComboBox.

Problem: I can't find a good way to specify a different cell editor for each row within a column. It's easy to choose an editor for the entire column, but in this case I may want to use different JComboBox options on different rows.

Sample Code: This code doesn't attempt to solve the entire problem, but shows the problem I'm running into right now. I have a debugging statement that writes out a message to the screen each time an ActionEvent occurs on a JComboBox within the first column. I'm trying to assign a unique ID to each JComboBox within each row so I can tell which one was chosen. That way I can tell which corresponding JComboBox in the second column to manipulate in response. However, every time an event is fired from the event-dispatching thread during execution, the same JComboBox is the source (it happens to always be the last one that was created).


This is just the last attempt I've made at this problem. I've been working on it sporatically for about a week. Please help if you have any experience with this.

[ June 20, 2005: Message edited by: Peter Glass ]
[ June 20, 2005: Message edited by: Peter Glass ]
 
Matthew Taylor
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind, I figured it out. The only way I could add a different renderer and editor for my table was to extend JTable and overwrite the getCellEditor(int row, int col) and getCellRender(int row, int col) methods.
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic