Package composants

Source Code of composants.JTextDate

package composants;

import java.util.Calendar;
import java.util.Date;

import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerNumberModel;
/**
*
* @author nelhassani
*
*/
public class JTextDate extends JSpinner {
  private JSpinner.DateEditor spinnerEditor;
  private SpinnerDateModel model;

  // -------------------------------------------------------------------------------
  public JTextDate() {
    this.setSize(200, 200);

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

    spinnerEditor = new DateEditor(this, "dd/MM/yyyy");
    this.setEditor(spinnerEditor);

  }

  // public JTextDate(int min,int max,int value,int step) {
  // model=new SpinnerNumberModel(value,min,max,step);
  // super.setModel(model);
  // spinnerEditor=new NumberEditor(this);
  // this.setEditor(spinnerEditor);
  // super.setModel(model);
  // }
  public String getSelectedNumber() {
    return spinnerEditor.getTextField().getText();
  }

  public void setSelectedNumber(int t) {
    spinnerEditor.getTextField().setText(String.valueOf(t));
  }
}
TOP

Related Classes of composants.JTextDate

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.