I have a JTable with 6 columns. for column 0 and 1 i have created a comboBox as editor. I want all the cells in the same row be edited when user select an item from combobox of column 0.
Does any one know if it is the best way or is there other way much better?
JTable table = new JTable();// a table with 6 columns
TableColumn column0 = tabel.getColumnModel().getColumn(0);
comboBox = new JComboBox(summary.getGenerics());
column0.setCellEditor(new DefaultCellEditor(comboBox));
column0.setCellRenderer(new DefaultTableCellRenderer());
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String selectedItem = comboBox.getSelectedItem().toString();
table.setValueAt("class" , table.getSelectedRow() , 1);
}
});