简体   繁体   English

从JComboBox中删除元素,一旦在另一个元素中选择它

[英]Remove element from JComboBox once selected in another

I've looked around on the internet but had no luck. 我在互联网上四处张望,但没有运气。 How would I go about solving this: 我将如何解决这个问题:

I have 4 JComboBoxes with identical data, and each time an element is selected, I want that element to be temporarily removed from all other JComboBoxes (until it's unselected). 我有4个具有相同数据的JComboBoxes,并且每次选择一个元素时,我都希望将该元素从所有其他JComboBoxes中临时删除(直到未选中)。

Since you have identical data, how about creating 4 temporary arrays and once you choose the selected index you may remove this index from other arrays. 由于您具有相同的数据,因此如何创建4个临时阵列,一旦选择了所选索引,就可以将该索引从其他阵列中删除。

Maybe this is not the best practice but will do the job until you have better solution. 也许这不是最佳实践,但是会一直有效,直到您有更好的解决方案为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM