Example usage for javax.swing JSpinner JSpinner

List of usage examples for javax.swing JSpinner JSpinner

Introduction

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

Prototype

public JSpinner(SpinnerModel model) 

Source Link

Document

Constructs a spinner for the given model.

Usage

From source file:SpinnerNumberSample.java

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

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

    JLabel label1 = new JLabel("Numbers");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.SOUTH);

    frame.setSize(200, 90);/*from  w w  w  .j  av  a  2s .  com*/
    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 model3 = new SpinnerNumberModel();
    JSpinner spinner3 = new JSpinner(model3);

    JLabel label3 = new JLabel("Numbers");
    JPanel panel3 = new JPanel(new BorderLayout());
    panel3.add(label3, BorderLayout.WEST);
    panel3.add(spinner3, BorderLayout.CENTER);
    frame.add(panel3, BorderLayout.SOUTH);

    frame.setSize(200, 90);/*from ww  w.  j  av  a2 s . c  om*/
    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 v a2s.  co  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: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  w w  w . j av a2  s  . c om*/

    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:MainClass.java

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

    SpinnerModel model3 = new RolloverSpinnerListModel(new String[] { "a", "b", "c" });
    JSpinner spinner3 = new JSpinner(model3);

    frame.add(spinner3, BorderLayout.SOUTH);

    frame.setSize(200, 90);/*from   ww  w.j av  a  2  s.  c  o m*/
    frame.setVisible(true);

}

From source file:SpinnerNumberEditorSample1.java

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

    SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25);
    JSpinner spinner = new JSpinner(model);
    JComponent editor = new JSpinner.NumberEditor(spinner);
    spinner.setEditor(editor);/*from w  ww.  j  ava 2s. 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:SpinnerNumberEditorSample2.java

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

    SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25);
    JSpinner spinner = new JSpinner(model);
    JComponent editor = new JSpinner.NumberEditor(spinner, "#,##0.###");
    spinner.setEditor(editor);/*from   w  w w.j a  va  2s.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:Main.java

public static void main(String[] argv) throws Exception {
    Calendar calendar = new GregorianCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, 13); // 1pm

    SpinnerDateModel dateModel = new SpinnerDateModel(calendar.getTime(), null, null, Calendar.HOUR_OF_DAY);
    JSpinner spinner = new JSpinner(dateModel);

    JFormattedTextField tf = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    DefaultFormatterFactory factory = (DefaultFormatterFactory) tf.getFormatterFactory();
    DateFormatter formatter = (DateFormatter) factory.getDefaultFormatter();

    // Change the date format to only show the hours
    formatter.setFormat(new SimpleDateFormat("hh:00 a"));
    //formatter.setFormat(new SimpleDateFormat("HH:00 a"));
}

From source file:Main.java

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

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("French Days/List");
    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);/*  w w  w. j  av  a 2 s  .co m*/
    frame.setVisible(true);
}

From source file:SpinnerStringsSample.java

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

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("French Days/List");
    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  a  v a2s. com*/
    frame.setVisible(true);
}