Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.ButtonModel;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class Main {
    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());
            }
        });

        JOptionPane.showMessageDialog(null, button);
    }
}