How do I Inserta JComboBox into a JTable?

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일

1 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

질문:

2012년 10월 2일

댓글:

2019년 8월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by