在一个jcombobox中进行选择启用另一个jcombobox [英] Make a selection in one jcombobox enable a different jcombobox
本文介绍了在一个jcombobox中进行选择启用另一个jcombobox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有7个jcombobox,它们都以相同的默认选择开头.如果在前面的jcombobox中选择了默认设置以外的其他选项,那么如何使下一个启用?
I have 7 jcomboboxes that all start with the same default selection. How do I make then next one enabled when something other than the default if selected in the preceding jcombobox?
if ( ! (custData1.equals("Please Select a Customer from the dropdown menu")) ){
custData2.setEnabled(true);
if ( ! (custData2.equals("Please Select a Customer from the dropdown menu")) ){
custData3.setEnabled(true);
if ( ! (custData3.equals("Please Select a Customer from the dropdown menu")) ){
custData4.setEnabled(true);
if ( ! (custData4.equals("Please Select a Customer from the dropdown menu")) ){
custData5.setEnabled(true);
if ( ! (custData5.equals("Please Select a Customer from the dropdown menu")) ){
custData6.setEnabled(true);
if ( ! (custData6.equals("Please Select a Customer from the dropdown menu")) ){
custData7.setEnabled(true);
}
}
}
}
}
}
这似乎不起作用...
This doesn't seem to work...
推荐答案
通过扩展JComboBox
创建自定义JComboBox
.使该类接受对前面组合框的引用.有它本身和作为
Create a custom JComboBox
by extends JComboBox
. Make that class take in a reference to the preceding combobox. Have it and itself as an ActionListener
to the preceding box and whenever an item is selected it should enable/disable itself.
这篇关于在一个jcombobox中进行选择启用另一个jcombobox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文