new JSpinner.DateEditor(JSpinner spinner, String dateFormatPattern) : JSpinner « javax.swing « Java by API






new JSpinner.DateEditor(JSpinner spinner, String dateFormatPattern)

 
import java.awt.Container;
import java.awt.FlowLayout;
import java.util.Calendar;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;

public class MainClass extends JFrame {

  public MainClass() {
    super("Month Spinner");
    setSize(200, 100);
    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);
  }

  public static void main(String args[]) {
    new MainClass();
  }
}

           
         
  








Related examples in the same category

1.JSpinner.NumberEditor.NumberEditor(JSpinner spinner)
2.new JSpinner(SpinnerModel model2)
3.new JSpinner(SpinnerModel model1) (SpinnerDateModel)
4.JSpinner: addChangeListener(ChangeListener lis)
5.JSpinner: getModel()
6.JSpinner: setEditor(JComponent editor)
7.JSpinner: setValue(Object value)