List of usage examples for javax.swing JSpinner commitEdit
public void commitEdit() throws ParseException
SpinnerModel
. From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);/*w w w. ja v a 2 s . 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); try { s.commitEdit(); } catch (ParseException e) { e.printStackTrace(); } }