2011-03-21 75 views
0

我有7個jcomboboxes,它們都以相同的默認選擇開始。如果在前面的jcombobox中選擇了默認值以外的其他值時,我該如何啓用下一個啓用項?在一個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); 
      } 
      } 
      } 
     } 
     } 
    } 

這似乎並沒有工作...

回答

1

創建自定義JComboBox通過延伸JComboBox。讓該課程參考前面的組合框。把它和它本身作爲一個ActionListener到前面的盒子,每當選擇一個項目時,它應該啓用/禁用它自己。