你好,我仍然是java新手希望學習這個不錯的功能... 你好,我有4個組合框有相同的內部和內部它是如果在jComBox1中選擇的項目,那麼它應該被禁用所有其他組合框
-Select-
Item 1
Item 2
Item 3
Item 4
,當我選擇Item 1
上comboBox1
, 的comboBox2,comboBox3 and comboBox4
有元素只有這些
-Select-
Item 2
Item 3
Item 4
,然後當我選擇Item 3
上comboBox2
,將comboBox3 and comboBox4
有這些剩餘的元素
-Select-
Item 2
Item 4
人有知道如何做到這一點關於Java?我使用的GUI Builder中的NetBeans ...
編輯1
這是我的代碼
private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
jComboBox2.removeItem(jComboBox1.getSelectedItem());
jComboBox3.removeItem(jComboBox1.getSelectedItem());
jComboBox4.removeItem(jComboBox1.getSelectedItem());
}
,我以後添加相同的代碼jComboBox2, jComboBox3 and jComboBox4
... 當我去選擇-Select-
-Select-
也不見了......而且
還有一個問題是當我已經選擇了所有想法並再次改變它......所有項目都沒有了, Ë選擇了..我只是想再次備份可用項...
EDIT 2
例
jComboBox1
-Select-
Item 1
Item 2 <-- I select Item2, then the other combo box will remove Item 2**
Item 3
Item 4
jComboBox2
-Select-
Item 1
Item 3 <-- then I select Item 3
Item 4
jComboBox3
-Select-
Item 1
Item 4 <-- then Item 4
jComboBox4
-Select-
Item 1
,但我改變了我的腦海裏......然後我需要回到jComboBox2
選擇Item3
所以我選擇 jComboBox2
並選擇-Select-
,所以我可以選擇item3
jComboBox4
但結果是 jComboBox4 空(無項目)
看起來像一個單一的'JList',允許選擇多個項目會更容易,並且最終用戶更容易混淆。這個'不錯的功能'讀起來像'製作中對我無用的GUI'。 –