开发者

Make a state change in one jcombobox enable a different jcombobox

I have 7 jcomboboxes, say: customerInfo1 customerInfo2 customerInfo3 customerInfo4 customerInfo5 customerInfo6 customerInfo7

All but the first one are set to setEnabled(false) and开发者_运维技巧 have setSelectedItem("Please Select a Customer from the dropdown menu"). I am having the hardest time figuring out how I would go about listening for a state change on customerInfo1 which would then make customerInfo2 setEnabled(true). And, once customerInfo2 is enabled have a state change event trigger the same thing for customerInfo3, and so on. Basically I don't want a given customerInfo jcombobox to be enabled until something other than what was initially set is selected in the preceding one. Your clear and specific help is much appreciated.


you can add a focus listener on the combo boxes such that if a combo has lost focus then you can check about the condition and take your action accordingly!!!

eg

  if we have a combo box then we would add a focus listener on it and check the condition whether the check box is checked or not then add the required combobox.

     JComboBox jb1;
     jb1.addFocusListener(this);

this is to be done in main and the following code in other method in the same class

     public void focusLost(FocusEvent fe) 
     {
          //your code for enabling or disabling the combo box
     }

this should do the required thing

Regards ChArAnJiT


You need to call a JavaScript method on change event of the first combo box.

Say if you change the state of the first combo box, this JavaScript method will be called and it will change the state of other combo boxes as u wish.

Same thing have to be done for all the other combo boxes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜