I'm trying to make a JTable, which has a JComboBox in a cell. I know that i could use a celleditor, but the trick is that i want different information in each row's combobox. Each row in the table represent an object, on that object are there an arraylist and it's content of that arraylist I want in the comboboxes. Here's my thought process so far.
table = new JTable(tableModel);
tableModel = new DefaultTableModel();
forestTable.setModel(tableModelForest);
tmpColum = forestTable.getColumnModel().getColumn(5);
tmpColum.setCellEditor(new DefaultCellEditor(comboBox));
comboBox = new JComboBox<Tree> ();
comboBox.setEditable(false);
Now when i later call the method(by pressing a button), i want to insert a new row with a unique combobox in coloum 5, but i have no idea how do it. I've tryed with.
public void fillTable(String text){
tableModel.insertRow(tableModel.getRowCount(), "" } );
tableModel.fireTableRowsInserted(
tableModel.getRowCount(),
tableModel.getRowCount());
comboBox.addItem(text);
}