java JComboBox的使用
JComboBox的itemStateChanged每次执行两次解决方法
String[] item = {"aaa","bbb","ccc","ddd"}; JComboBox jcb = new JComboBox(item); jcb.addItemListener(new ItemListener(){ @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED)//需要加上这句,因为Change有DESELECTED和SELECTED两种情况 System.out.println((String)e.getItem()); } });