Forums Register Login

Using Mutilple Cell Editor on single column of JTable

+Pie Number of slices to send: Send
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???
+Pie Number of slices to send: Send
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
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1079 times.
Similar Threads
JTable customization
jtable
JTable
JList or JTable
JComboBox as Cell renderer in JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:50:44.