List of usage examples for javax.swing ButtonModel addChangeListener
void addChangeListener(ChangeListener l);
ChangeListener
to the model. From source file:Main.java
public static void main(String[] args) { JButton button = new JButton("Test"); ButtonModel model = button.getModel(); model.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Armed: " + model.isArmed() + " Enabled: " + model.isEnabled() + " Pressed: " + model.isPressed()); }//from w w w.java 2 s .c om }); JOptionPane.showMessageDialog(null, button); }