Example usage for javax.swing ButtonModel addChangeListener

List of usage examples for javax.swing ButtonModel addChangeListener

Introduction

In this page you can find the example usage for javax.swing ButtonModel addChangeListener.

Prototype

void addChangeListener(ChangeListener l);

Source Link

Document

Adds a ChangeListener to the model.

Usage

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);
}