Re: Using a JComboBox in certain cells in a JTable



1. Override JTable
public Component prepareRenderer(TableCellRenderer,int,int)
2. Override DefautlTableCellRenderer
public Component getTableCellRendererComponent(JTable,Object,


                                 boolean,boolean,int,int)
3. Create your own renderer (has to implement TableCellRenderer)

I prefer #3.

Leif Bloomquist wrote:
Hi all,

Using the techniques from the following page, I've set up a JTable with
JComboBoxes in one column of cells.
http://javaalmanac.com/egs/javax.swing.table/ComboBox.html

However, what I'd really like to do is have a JComboBox as the editor/render
for only certain cells in the column, not the entire column.  I found a
verbal solution here:
https://lists.xcf.berkeley.edu/lists/advanced-java/2000-March/007761.html

So I get what they're saying - check the row that is currently being
edited/rendered, and return either a JComboBox for those rows, or a "normal"
JTable cell.  (Is it a JTextField?)  But I'm a bit fuzzy on where/when I
should actually put in the code that does this.  Can anyone help or provide
a short example?

Thanks,
Leif

.