Example usage for javax.swing JSpinner setEditor

List of usage examples for javax.swing JSpinner setEditor

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, description = "JComponent that displays the current value of the model")
public void setEditor(JComponent editor) 

Source Link

Document

Changes the JComponent that displays the current value of the SpinnerModel.

Usage

From source file:MainClass.java

public MainClass() {
    super("JSpinner Icon Test");
    setSize(300, 80);/*from   w w  w. j a v a  2 s.  c  o m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

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

    Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"),
            new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") };
    JSpinner s1 = new JSpinner(new SpinnerListModel(nums));
    s1.setEditor(new IconEditor(s1));
    c.add(new JLabel(" Icon Spinner"));
    c.add(s1);

    setVisible(true);
}

From source file:Main.java

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

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

    Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"),
            new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") };
    JSpinner s1 = new JSpinner(new SpinnerListModel(nums));
    s1.setEditor(new IconEditor(s1));

    System.out.println(s1.getEditor());

    c.add(new JLabel(" Icon Spinner"));
    c.add(s1);

    setVisible(true);
}

From source file:Main.java

public Main() {
    super("JSpinner Icon Test");
    setSize(300, 80);/*ww  w .j  a  v a2s.  c  o m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

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

    Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"),
            new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") };
    JSpinner s1 = new JSpinner(new SpinnerListModel(nums));
    s1.setEditor(new IconEditor(s1));
    c.add(new JLabel(" Icon Spinner"));
    c.add(s1);

    setVisible(true);
}

From source file:IconSpinner.java

public IconSpinner() {
    super("JSpinner Icon Test");
    setSize(300, 80);//from   w  ww.jav  a2s.co  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

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

    Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"),
            new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") };
    JSpinner s1 = new JSpinner(new SpinnerListModel(nums));
    s1.setEditor(new IconEditor(s1));
    c.add(new JLabel(" Icon Spinner"));
    c.add(s1);

    setVisible(true);
}

From source file:Main.java

public Main() {
    super("Month Spinner");
    setSize(200, 100);/* www. ja va2 s .co m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    SpinnerDateModel model = new SpinnerDateModel(today, null, null, Calendar.MONTH);
    JSpinner s = new JSpinner();
    s.setModel(model);
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);

    c.add(s);

    setVisible(true);
}

From source file:Main.java

public Main() {
    setSize(200, 100);/*  w w  w  .  j av a2 s  . c  o m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    add(s);

    setVisible(true);
}

From source file:Main.java

public Main() {
    super("Month Spinner");
    setSize(200, 100);/*from   www  .jav  a  2s .  c o  m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);
}

From source file:MainClass.java

public MainClass() {
    super("Month Spinner");
    setSize(200, 100);//from   ww  w . ja  v a2  s . co m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);
}

From source file:Main.java

public Main() {
    setSize(200, 100);/*from w w  w . ja v  a 2 s. co  m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    // Start the spinner today, but don't set a min or max date
    // The increment should be a month
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);
}

From source file:Main.java

public Main() {
    super("Month Spinner");
    setSize(200, 100);/* w w w. j  a va 2s.com*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));

    c.add(new JLabel("Expiration Date:"));
    Date today = new Date();
    JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH));
    JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy");
    s.setEditor(de);
    c.add(s);

    setVisible(true);

    System.out.println(s.getNextValue());
}