aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Using Mutilple Cell Editor on single column of JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Using Mutilple Cell Editor on single column of JTable" Watch "Using Mutilple Cell Editor on single column of JTable" New topic
Author

Using Mutilple Cell Editor on single column of JTable

Gauhar Khan
Greenhorn

Joined: Jun 17, 2005
Posts: 6
Hi All,

Can any body tell me how to specify multiple cell editor on a single column of a JTable.
i.e I want to use JTextField to edit cell indexed at(1,2)...JCombobox to edit cell indexed at(2,2)...JLabel to edit cell at(3,2)...what should i do to Code it???
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I just did this (I think my method is kind of a hack, but it works).
I created another column in the table that holds the celleditor (drop down box or JText field) and I overrode the getCellEditor method to return the one that is in the adjacent column. Of course you want to remove this column from the table before displaying it.

If you know before hand what cells require what types of editor, you could also just do a switch/if statement to return the right editor.

-Tad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Mutilple Cell Editor on single column of JTable
 
Similar Threads
JTable customization
JTable
jtable
JComboBox as Cell renderer in JTable
JList or JTable