Example usage for javax.swing SpinnerListModel SpinnerListModel

List of usage examples for javax.swing SpinnerListModel SpinnerListModel

Introduction

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

Prototype

public SpinnerListModel(Object[] values) 

Source Link

Document

Constructs a SpinnerModel whose sequence of values is defined by the specified array.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    SpinnerListModel listModel = new SpinnerListModel(new String[] { "red", "green", "blue" });
    JSpinner spinner = new JSpinner(listModel);

    spinner.setValue("blue");
}

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  . jav  a2 s  .  c  o m*/
    f.setVisible(true);
}

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.java  2s  . c om*/
    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   ww  w  .j av  a2s .c om*/
    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);//ww w  .  ja v  a 2s  .  c  o 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: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);// ww  w.  j  a  v  a2  s.  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 w ww.  java 2  s  . c o  m
    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:Main.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);

    ChangeListener listener = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            System.out.println("Source: " + e.getSource());
        }/* www  . j  a  va 2 s .  c o  m*/
    };

    spinner1.addChangeListener(listener);

    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);
    frame.setVisible(true);
}

From source file:Main.java

public ColorSpinner(String[] colorNames) {
    super();/*from ww w .  ja v  a 2 s.c  o m*/
    setModel(new SpinnerListModel(colorNames));
    setEditor(new Editor(this));
}

From source file:Main.java

public Main() {
    JSpinner m_listSpinner;/* ww w  .ja v a 2s .c  o m*/
    SpinnerListModel m_listSpinnerModel;
    List<String> sequence = new ArrayList<String>();

    sequence.add(new String("I - First"));
    sequence.add(new String("II - Second"));
    sequence.add(new String("III - Third"));
    sequence.add(new String("IV - Fourth"));
    sequence.add(new String("V - Fifth"));
    sequence.add(new String("VI - Sixth"));

    m_listSpinnerModel = new SpinnerListModel(sequence);

    m_listSpinner = new JSpinner(m_listSpinnerModel);
    add(m_listSpinner);
}