Update:. When I tested my (possibly incomplete) answer, I came across a very good SO question, which I think will help a lot better than I could: Enabling JComboBox in JTable
Another update: I read your question again, and realized that you asked a specific line . The only way I can do this is to create a custom CellEditor, something like:
private static class MyCellEditor extends AbstractCellEditor implements TableCellEditor { DefaultCellEditor other = new DefaultCellEditor(new JTextField()); DefaultCellEditor checkbox = new DefaultCellEditor(new JComboBox(new Object[] {"abc"})); private DefaultCellEditor lastSelected; @Override public Object getCellEditorValue() { return lastSelected.getCellEditorValue(); } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if(row == 0) { lastSelected = checkbox; return checkbox.getTableCellEditorComponent(table, value, isSelected, row, column); } lastSelected = other; return other.getTableCellEditorComponent(table, value, isSelected, row, column); } }
In this example, the custom CellEditor is actually two Editors, and depending on the selected row, the particular editor will receive a call (both figuratively and literally). I admit that lastSelected seemed a bit hokey, but I honestly couldn't find an easier way to find out what value the editor needs to return (since getCellEditorValue has no arguments).
To make your table look βright,β you probably have to do something with Renderer (because Renderer may or may not know to show the selected JComboBox value as the initial value). It depends on how you initialize the data in the actual table.
To complete my initial answer below:
You can add the JComboBox component to the line using addRow in TableModel as below: How to add a row in JTable?
See also: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html
I think the main problem is that you are mixing the idea of ββColumn Editors / Renderers with the actual data that will be stored on each row.