Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class Main {

    public static void main(final String args[]) {
        JFrame frame = new JFrame("JSpinner Dates");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        ChangeListener listener = new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                System.out.println("Source: " + e.getSource());
            }
        };

        SpinnerModel model3 = new SpinnerNumberModel();
        JSpinner spinner3 = new JSpinner(model3);
        spinner3.addChangeListener(listener);

        ChangeListener[] changeListeners = spinner3.getChangeListeners();

        frame.add(spinner3, BorderLayout.SOUTH);

        frame.setSize(200, 90);
        frame.setVisible(true);

    }

}