Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;
import java.awt.Container;
import java.util.Calendar;

import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;

public class Main {
    public static void main(String args[]) {
        JFrame frame = new JFrame("Spinning");
        Container contentPane = frame.getContentPane();
        String months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September",
                "October", "November", "December" };
        SpinnerModel model = new SpinnerListModel(months);
        JSpinner spinner = new JSpinner(model);
        contentPane.add(spinner, BorderLayout.NORTH);

        SpinnerDateModel model2 = new SpinnerDateModel();
        model2.setCalendarField(Calendar.WEEK_OF_MONTH);
        JSpinner spinner2 = new JSpinner(model2);
        JSpinner.DateEditor editor2 = new JSpinner.DateEditor(spinner2, "MMMMM dd, yyyy");
        spinner2.setEditor(editor2);
        frame.getContentPane().add(spinner2, BorderLayout.CENTER);

        SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5);
        JSpinner spinner3 = new JSpinner(model3);
        frame.getContentPane().add(spinner3, BorderLayout.SOUTH);

        frame.setSize(200, 100);
        frame.setVisible(true);
    }
}