1
我有已用於填充ComboBox
(經理)對象的ArrayList
,如下所示:基於爪哇組合框依賴於另一組合框
testingPeople people = new testingPeople();
people.loadPeople();
ArrayList<Person> testing = new ArrayList<Person>();
testing = people.getManagerList();
for (int i=0; i < testing.size(); i++) {
jComboBox1.addItem(testing.get(i));
}
現在,我要填充第二ComboBox
(下屬)取決於第一個ComboBox
中選擇的值。在事件處理程序中,我嘗試了以下內容:
if (jComboBox1.getSelectedItem().equals("Insert Name here")) {
jComboBox2.addItem("it works!");
}
而且,其他變體,但我仍畫空白。
有人請賜教。