how to add different cell editors for one column in JTable?

java, swing

Solution

You need to implement your own `javax.swing.table.TableCellRenderer`, where return different renderers at `getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)` according to your business logic. The same for `TableCellEditor` Interface.

Problem

I have a JTable with two columns and both are JComboBox, for this purpose I implemented my own Model and overrode methods. One of the method which I overrode is: ``` public Class getColumnClass(int index) { return JComboBox.class; } ``` Also created my own ComboBoxEditor and ComboBoxRender classes, and set cellEditor and cellRenderer: ``` column.setCellEditor(new ComboBoxEditor()); column.setCellRenderer(new ComboBoxRenderer()); ``` Now I want to make changes, so that for column one some cells are JComboBox and some cells are standard textual data. How can I achieve this ? Any helpful suggestions would be welcome

Original source