JTable中的JComboBox [英] JComboBox in JTable
本文介绍了JTable中的JComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在JTable的第3和第4列中有一个JComboBox,但我不知道如何获取其项目...问题不是获取项目的方法,而是演员
I've a JComboBox in 3rd and 4th column of a JTable but I don't know how to get its items...the problem isn't the method to get items but the cast
JComboBox combo=(JComboBox) jTable1.getColumnModel().getColumn(3).getCellEditor();
你能帮我吗?
推荐答案
JComboBox
包装在CellEditor
中.您必须检索包装的组件,例如在使用DefaultCellEditor
时:
The JComboBox
is wrapped in a CellEditor
. You must retrieve the wrapped component, for example when using DefaultCellEditor
:
DefaultCellEditor editor = (DefaultCellEditor)table.getColumnModel().getColumn(3).getCellEditor();
JComboBox combo = (JComboBox)editor.getComponent();
这篇关于JTable中的JComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文