How do I Inserta JComboBox into a JTable?

10 ビュー (過去 30 日間)
David
David 2012 年 10 月 2 日
コメント済み: Arwel 2019 年 8 月 6 日
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.

採用された回答

CYSO
CYSO 2013 年 11 月 26 日
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 件のコメント
Arwel
Arwel 2019 年 8 月 6 日
How can you then get/set values in each combobox individually?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MuPAD についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by