This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to add different Comobox in each cell of a Column in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add different Comobox in each cell of a Column in JTable" Watch "How to add different Comobox in each cell of a Column in JTable" New topic
Author

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

buntha Choudhary
Ranch Hand

Joined: Jul 03, 2009
Posts: 136

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

Joined: Oct 27, 2005
Posts: 20080
    
  30

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
Have you checked out Aspose?
 
subject: How to add different Comobox in each cell of a Column in JTable
 
It's not a secret anymore!