Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add different Comobox in each cell of a Column in JTable

 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable with Column 1 as a JComboBox Editor.
Now when I am using that, for column 1 each column is taking same set of ComboBox Items. But I want each column to take different items for ComboBox.
I am using
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extend DefaultCellEditor. Override getTableCellEditorComponent. Call super.getTableCellEditorComponent(...), cast the result to JComboBox, then set the model for that combo box:
You'll need to write the code to determine / find / create the model yourself, but this is the basic idea.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic