MATLAB: How tonserta JComboBox into a JTable

comboboxguijavajtable

I would like to place a JComboBox in each cell in a column of a JTable. I have found plenty of Java code demonstrating how to do this, but I can't seem to get it working in MATLAB. I understand that I need to set the cell's default editor property to that of the combo box, but haven't succeeded.

Best Answer

use this code^^
mtable = uitable ('Data',magic(3),'ColumnNames',{'A','B','C'});
jtable = mtable.getTable;
comboBox = javax.swing.JComboBox({'First','Last'});
comboBox.setEditable(true);
editor = javax.swing.DefaultCellEditor(comboBox);
jtable.getColumnModel.getColumn(0).setCellEditor(editor);