[英]Return JComboBox from JTable
so I've got a number of JComboBox's which make up a JTable. 所以我有一些构成JTable的JComboBox。 My question is;
我的问题是; without having access to these JComboBox's directly, how can I obtain them from the JTable?
如果没有直接访问这些JComboBox,我如何从JTable获取它们? Below is how I've put the JComboBoxes into the JTable...
下面是我如何将JComboBox放入JTable ......
TableColumn columnModel = table.getColumnModel().getColumn(i);
columnModel.setCellEditor(new DefaultCellEditor(combo));
...So I would imagine that you can return them by doing something like... ...所以我想你可以通过做类似的事情来回报它们......
JComboBox retrievedDropDowns = (JComboBox)table.getColumnModel().getColumn(1).getCellEditor();
But apparently not... 但显然不是......
Am I far off? 我远吗?
Thanks! 谢谢!
尝试:
JComboBox retrievedDropDowns = (JComboBox)table.getColumnModel().getColumn(i).getCellEditor().getComponent();
If you put a DefaultCellEditor
in your columnModel then it will return a DefaultCellEditor
not a JComboBox
. 如果在columnModel中放置
DefaultCellEditor
,则它将返回DefaultCellEditor
而不是JComboBox
。
But you can use DefaultCellEditor.getComponent()
to get the inner editorComponent. 但是您可以使用
DefaultCellEditor.getComponent()
来获取内部editorComponent。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.