我怎樣才能讓組合框時可用的複選框取消選中了(反之亦然)激活和關閉組合框
爲什麼下拉框中仍然禁用後,我未選中的複選框?
choice [] = {"A","B","C"};
JComboBox a = new JComboBox(choice);
JCheckBox chk = new JCheckBox("choice");
...
a.addActionListener(this);
chk.addActionListener(this);
...
public void actionPerformed(ActionEvent e) {
//disable the a comboBox when the checkBox chk was checked
if(e.getSource()==chk)
a.setEnabled(false);
//enable the a comboBox when the checkBox chk was unchecked
else if(e.getSource()!=chk)
a.setEnabled(true);
}
謝謝,這是我需要的:-) – Jessy 2010-03-31 12:14:21