如何在netbeans中将jcombobox添加到jtable列 [英] how to add jcombobox to jtable column in netbeans
问题描述
我想要将jcombobox添加到jtable请有人解释我怎么能在netbeans中做到这一点
添加 JComboBox
通过在框架或面板外拖放。因此它将被添加到导航器视图中的 OtherComponents
通过双击Navaigator视图中的组合框添加要添加的任何内容
然后右键单击 JTable
并单击TableContents
在对话框中选择列
选项卡(1)并选择要将组合框添加到的列(2)。 / p>
然后点击编辑器附近的按钮[参考屏幕截图ot(3)]
然后在编辑器对话框中从下拉列表中选择自定义代码
然后输入以下(5)
new DefaultCellEditor(jComboBox1)// jComboBox1是组合框的变量名
然后单击确定并关闭并确保导入导入javax。 swing.DefaultCellEditor;
或执行 Ctrl + Shift + I
添加必要的导入
之后如果您运行并单击第2列,您将获得此输出
I want to add jcombobox to jtable please someone explain me how could i do that in netbeans
Add a JComboBox
by dragging and dropping outside the frame or panel.So that it will be added to OtherComponents
in the Navigator View
Add whatever contents you want to add by double clicking the combobox from Navaigator View
Then rightclick on JTable
and click TableContents
In the Dialog select Columns
Tab(1) and select the column(2) you want to add the combobox to.
Then Click on the button near to the Editor[Ref screenshot (3)]
Then in the editor dialog Choose Custom Code
from the dropdown(4)
Then put the following(5)
new DefaultCellEditor(jComboBox1)//jComboBox1 is the variable name of combobox
Then Click ok and close and make sure you import import javax.swing.DefaultCellEditor;
or do a Ctrl+Shift+I
to add the necessary imports
After that If you run and click on column 2 you'll get this output
这篇关于如何在netbeans中将jcombobox添加到jtable列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!