我有7个jcombobox,它们都以相同的默认选择开始。如果在前面的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);
}
}
}
}
}
}
这似乎不起作用......
答案 0 :(得分:1)
通过扩展JComboBox
创建自定义JComboBox
。使该类参考前面的组合框。将它和它自己作为前一个框的ActionListener
,每当选择一个项目时,它应该启用/禁用它自己。