Examples of SpinnerDateModel


Examples of javax.swing.SpinnerDateModel

    Date v1 = new Date(now.getTime() - 1L);
    Date start = new Date(now.getTime() - 2L);
    Date preStart = new Date(now.getTime() - 3L);
    Date end = new Date(now.getTime() + 2L);
    Date postEnd = new Date(now.getTime() + 3L);
    SpinnerDateModel m = new SpinnerDateModel(now, start, end,
            Calendar.MILLISECOND);
    m.addChangeListener(this);
    m.setValue(v1);
    harness.check(m.getValue(), v1);
    harness.check(this.event.getSource(), m);
   
    // same value triggers no event
    this.event = null;
    m.setValue(v1);
    harness.check(this.event == null);
   
    // set value less than start
    m.setValue(preStart);       
    harness.check(m.getValue(), preStart);

    // set value greater than maximum
    m.setValue(postEnd);       
    harness.check(m.getValue(), postEnd);
 
    // set null value
    boolean pass = false;
    try
    {
      m.setValue(null);       
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // set a non-date value
    pass = false;
    try
    {
      m.setValue("123");       
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
View Full Code Here

Examples of javax.swing.SpinnerDateModel

    Date now = new Date();
    Date prev = new Date(now.getTime() - 1L)
    Date start = new Date(now.getTime() - 2L);
    Date end = new Date(now.getTime() + 2L);
     
    SpinnerDateModel m = new SpinnerDateModel(now, start, end,
              Calendar.MILLISECOND);
    harness.check(m.getValue(), now);
    harness.check(m.getPreviousValue(), prev);
   
    // accessing the previous value doesn't update the current value
    harness.check(m.getValue(), now);
    m.setValue(prev);
    harness.check(m.getPreviousValue(), start);
    m.setValue(start);
    harness.check(m.getPreviousValue(), null);
   
    // repeat for model without bounds
    m = new SpinnerDateModel(now, null, null, Calendar.MILLISECOND);
    harness.check(m.getValue(), now);
    harness.check(m.getPreviousValue(), prev);

    // accessing the previous value doesn't update the current value
    harness.check(m.getValue(), now);   
  }
View Full Code Here

Examples of javax.swing.SpinnerDateModel

    harness.check(e1 instanceof JSpinner.NumberEditor);
    // no listeners added to the editor yet
    EventListener[] e1l = e1.getListeners(ChangeListener.class);
    harness.check(e1l.length, 0);
   
    SpinnerModel m2 = new SpinnerDateModel();
    MyJSpinner s2 = new MyJSpinner(m2);
    JComponent e2 = s2.createEditor(m2);
    harness.check(e2 instanceof JSpinner.DateEditor);
    // no listeners added to the editor yet
    EventListener[] e2l = e2.getListeners(ChangeListener.class);
View Full Code Here

Examples of javax.swing.SpinnerDateModel

 
   public void test(TestHarness harness)
   {
     harness.checkPoint("()");
     JSpinner s = new JSpinner();
     SpinnerDateModel m = new SpinnerDateModel();
     s.setModel(m);
     harness.check(s.getModel(), m);
   }
View Full Code Here

Examples of javax.swing.SpinnerDateModel

  }
 
  public void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("(JSpinner)");
    SpinnerDateModel m = new SpinnerDateModel();
    JSpinner s = new JSpinner(m);
    JSpinner.DateEditor e = new JSpinner.DateEditor(s);
    harness.check(e.getFormat(), DateFormat.getInstance());
    harness.check(e.getLayout(), e);
    JFormattedTextField ftf = e.getTextField();
    DateFormatter nf = (DateFormatter) ftf.getFormatter();
    harness.check(nf.getMinimum(), null);
    harness.check(nf.getMaximum(), null);
   
    m = new SpinnerDateModel(new Date(50L), new Date(0L), new Date(100L),
            Calendar.MILLISECOND);
    s = new JSpinner(m);
    e = new JSpinner.DateEditor(s);
    harness.check(e.getFormat(), DateFormat.getInstance());
    ftf = e.getTextField();
View Full Code Here

Examples of javax.swing.SpinnerDateModel

  }

  public void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("(JSpinner, String)");
    SpinnerDateModel m = new SpinnerDateModel();
    JSpinner s = new JSpinner(m);
    JSpinner.DateEditor e = new JSpinner.DateEditor(s, "S");
    harness.check(e.getFormat(), new SimpleDateFormat("S"));
    harness.check(e.getLayout(), e);
   
View Full Code Here

Examples of javax.swing.SpinnerDateModel

   {
     harness.checkPoint("(SpinnerModel)");
     JSpinner s = new JSpinner();
     harness.check(s.getEditor() instanceof JSpinner.NumberEditor);
     s.addPropertyChangeListener(this);
     SpinnerDateModel m = new SpinnerDateModel();
     s.setModel(m);
     harness.check(s.getModel(), m);
     harness.check(events.size(), 2);
     PropertyChangeEvent e1 = (PropertyChangeEvent) events.get(0);
     harness.check(e1.getPropertyName(), "model");
View Full Code Here

Examples of javax.swing.SpinnerDateModel

public class getFormat implements Testlet
{
  public void test(TestHarness harness)
  {
    harness.checkPoint("()");
    SpinnerDateModel m = new SpinnerDateModel();
    JSpinner s = new JSpinner(m);
    JSpinner.DateEditor e = new JSpinner.DateEditor(s);
    harness.check(e.getTextField().getFormatterFactory()
        instanceof DefaultFormatterFactory);
    harness.check(e.getFormat(), DateFormat.getInstance());
View Full Code Here

Examples of javax.swing.SpinnerDateModel

  protected String dateFormatString;

  protected SimpleDateFormat dateFormatter;

  public JSpinnerDateEditor() {
    super(new SpinnerDateModel());
    dateFormatter = (SimpleDateFormat) DateFormat
        .getDateInstance(DateFormat.MEDIUM);
    ((JSpinner.DateEditor) getEditor()).getTextField().addFocusListener(
        this);
    DateUtil dateUtil = new DateUtil();
View Full Code Here

Examples of javax.swing.SpinnerDateModel

  private static final String TIME_FORMAT = "hh:mm a";
  private static final SimpleDateFormat timeSDF = new SimpleDateFormat(TIME_FORMAT);
  private JLabel label = null;

  public XTime(XEditor panel, SpringLayout layout, String name, String title, int width) {
    super(new SpinnerDateModel());
    JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(this, TIME_FORMAT);
    this.setEditor(timeEditor);
    this.setValue(new Date()); // will only show the current time

    this.setName(name);
View Full Code Here
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.