2017-12-28 2 views
-1

항목이 JComboBox1에서 항목을 선택하려고 할 때 JComboBox1에서 항목을 선택하려고 할 때 JComboBox2에 중복 항목이 표시되지만 JComboBox1에서 다른 항목을 선택했을 때 다시 선택 이전 항목이 JCBoBox2에 복제 됨항목 Listener의 단일 선택 항목에 대해 수행되는 작업이 2 개 인 이유는 무엇입니까?

나는이

String Selected=(String) jComboBox1.getSelectedItem(); 
    if (ie.getStateChange() == ItemEvent.SELECTED) { 

if(Selected.equalsIgnoreCase("Delivery Status")) 
{ 
    jComboBox2.addItem("Delivered"); 
    jComboBox2.addItem("Not Delivered"); 

} 
} else if(ie.getStateChange() == ItemEvent.DESELECTED){ 
    jComboBox2.removeAll(); 
} 

enter image description here

enter image description here

[1]: https://i.stack.imgur.com/J2cBU.png을 tryed

답변

0

JComboBox의 선택을 변경하면, 항목 청취자는 선택 해제 된 항목에 대해 한 번, 선택한 항목에 대해 다른 항목이 한 번씩 두 번 통보됩니다.

관련 문제