This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JComboBoxes dependency in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBoxes dependency in JTable " Watch "JComboBoxes dependency in JTable " New topic
Author

JComboBoxes dependency in JTable

Radek Gajdos
Ranch Hand

Joined: Sep 22, 2013
Posts: 32
Hi, my question is if it's possible to make "interactive" JComboBox in JTable, this interactiveness should depends on selection item in one box and then the items of second box should change depending on the choice in the first box. I have write some code allready but it doesn't work as it should be, every advices are welcome.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
Override the getCellEditor(...) method of JTable to determine which combo box to use.

Here is an example that changes the combo box based on the selected row. In your case you would choose which combo box to used based on the value of the related column.

Radek Gajdos
Ranch Hand

Joined: Sep 22, 2013
Posts: 32
Thank you Rob for your suggestion, i have overrided the getCellEditor(...) method of JTable and it works perfectly. Below fully runable code. Thank you one more time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBoxes dependency in JTable
 
Similar Threads
Saving and Loading content of JTable
Problem in adding/deleting rows from Jtable
Get creation time for adding a new row in jtable
adding a row to a jtable by pressing a key
Counting occurrence of an item in JTable