Example usage for javax.swing SpinnerDateModel SpinnerDateModel

List of usage examples for javax.swing SpinnerDateModel SpinnerDateModel

Introduction

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

Prototype

public SpinnerDateModel() 

Source Link

Document

Constructs a SpinnerDateModel whose initial value is the current date, calendarField is equal to Calendar.DAY_OF_MONTH, and for which there are no start/end limits.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    SpinnerDateModel dateModel = new SpinnerDateModel();
    JSpinner spinner = new JSpinner(dateModel);

    Calendar calendar = new GregorianCalendar(2000, Calendar.JANUARY, 1);
    spinner.setValue(calendar.getTime());
}

From source file:SpinnerDateSample.java

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

    SpinnerModel model1 = new SpinnerDateModel();
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("Dates/Date");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.CENTER);

    frame.setSize(200, 90);/* w  w w  . ja  v a  2  s  . c om*/
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("JSpinner Dates");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    SpinnerModel model1 = new SpinnerDateModel();
    JSpinner spinner1 = new JSpinner(model1);
    JLabel label1 = new JLabel("All");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);/*from w w  w  .  j  ava2  s . co m*/
    frame.setVisible(true);

}

From source file:SpinnerDateEditorSample.java

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

    SpinnerModel model = new SpinnerDateModel();
    JSpinner spinner = new JSpinner(model);
    JComponent editor = new JSpinner.DateEditor(spinner, "MMMM yyyy");
    spinner.setEditor(editor);/*from w w w.  j  a  va 2 s .  com*/

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(spinner, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.SOUTH);

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

From source file:SpinnerDateEditorSample1.java

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

    SpinnerModel model = new SpinnerDateModel();
    JSpinner spinner = new JSpinner(model);
    JComponent editor = new JSpinner.DateEditor(spinner);
    spinner.setEditor(editor);/*from  www .  ja v  a2 s . c  o m*/

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(spinner, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.SOUTH);

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

From source file:SpinnerDemo.java

public static void main(String[] args) {
    JFrame jf = new JFrame("It Spins");
    Container cp = jf.getContentPane();
    cp.setLayout(new GridLayout(0, 1));

    // Create a JSpinner using one of the pre-defined SpinnerModels
    JSpinner dates = new JSpinner(new SpinnerDateModel());
    cp.add(dates);//from ww  w  .  j a v a2 s . co m

    // Create a JSPinner using a SpinnerListModel. 
    String[] data = { "One", "Two", "Three" };
    JSpinner js = new JSpinner(new SpinnerListModel(data));
    cp.add(js);

    jf.setSize(100, 80);
    jf.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JSpinner Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);
    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    SpinnerModel model2 = new SpinnerDateModel();
    JSpinner spinner1 = new JSpinner(model1);
    JSpinner spinner2 = new JSpinner(model2);
    f.add(spinner1, BorderLayout.NORTH);
    f.add(spinner2, BorderLayout.SOUTH);
    f.setSize(300, 100);// w w  w. ja  v  a 2  s.co  m
    f.setVisible(true);
}

From source file:Main.java

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);/* www  .  j a v  a 2s . c om*/
    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);
}

From source file:SpinnerTest.java

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);//from www .  j  ava2  s. com
    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.show();
}

From source file:SwingSpinnerTest.java

public SwingSpinnerTest() {
    super("JSpinner Test");
    setSize(300, 180);//from   ww w .  j a  va  2  s  .com
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new GridLayout(0, 2));

    c.add(new JLabel(" Basic Spinner"));
    c.add(new JSpinner());

    c.add(new JLabel(" Date Spinner"));
    c.add(new JSpinner(new SpinnerDateModel()));

    String weekdays[] = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
            "Saturday" };
    c.add(new JLabel(" List Spinner"));
    c.add(new JSpinner(new SpinnerListModel(weekdays)));

    c.add(new JLabel(" Number Spinner"));
    c.add(new JSpinner(new SpinnerNumberModel(0, 0, 100, 5)));

    c.add(new JLabel(" Rollover List Spinner"));
    c.add(new JSpinner(new RolloverSpinnerListModel(weekdays)));

    setVisible(true);
}