Can you catch/suppress events?
I have a subroutine that updates items in a form, but I don't want it to generate any action events. Is there a way to catch events or suppress event generation in a subroutine? I still want the application to recognize events generated by user input.
Example:
Code:
import java.awt.event.*;
import javax.swing.*;
public class MyPanel extends JPanel implements ActionListener {
private JComboBox boxA;
private JCheckBox check;
private MyObject someObject;
public MyPanel(MyObject anObject) {
this.boxA = new JComboBox();
this.boxA.addItem("Item1");
this.boxA.addItem("Item2");
this.boxA.addActionListener(this);
this.check = new JCheckBox();
this.check.addActionListener(this);
this.add(boxA);
this.add(check);
this.someObject = anObject;
}
// this method I do not want to generate any events
public void update(String cbData, boolean isCheck) {
this.boxA.setSelectedItem(cbData);
this.check.setSelected(isCheck);
}
// this method should be able to get events triggered by user
public void ActionPerformed(ActionEvent ae) {
// get swing component values and update someObject
...
}
}