How do I Inserta JComboBox into a JTable?

10 Ansichten (letzte 30 Tage)
David
David am 2 Okt. 2012
Kommentiert: Arwel am 6 Aug. 2019
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.

Akzeptierte Antwort

CYSO
CYSO am 26 Nov. 2013
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);
  1 Kommentar
Arwel
Arwel am 6 Aug. 2019
How can you then get/set values in each combobox individually?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MuPAD finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by