在一个 jcombobox 中进行状态更改启用不同的 jcombobox
我有 7 个 jcomboboxes,比如说: 客户信息1 客户信息2 客户信息3 客户信息4 客户信息5 客户信息6 customerInfo7
除第一个之外的所有内容均设置为 setEnabled(false) 并具有 setSelectedItem("请从下拉菜单中选择客户")。我最难弄清楚如何监听 customerInfo1 上的状态更改,然后使 customerInfo2 setEnabled(true) 。并且,一旦启用了 customerInfo2,状态更改事件就会触发 customerInfo3 的相同事件,依此类推。基本上,我不希望启用给定的 customerInfo 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在组合框上添加焦点侦听器,这样如果组合失去焦点,您就可以检查情况并采取相应的操作!
例如,
这将在 main 中完成,并且以下代码在同一类中的其他方法中完成,
这应该执行所需的操作
问候
查兰吉特
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
this is to be done in main and the following code in other method in the same class
this should do the required thing
Regards
ChArAnJiT
您需要在第一个组合框的更改事件上调用 JavaScript 方法。
假设如果您更改第一个组合框的状态,则会调用此 JavaScript 方法,并且它将根据您的意愿更改其他组合框的状态。
必须对所有其他组合框执行相同的操作。
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.