Package javax.swing

Examples of javax.swing.SpinnerNumberModel


    this.event = e;   
  }
 
  public void test(TestHarness harness)
  {
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    m.addChangeListener(this);
    m.setMaximum(new Double(3.7));
    harness.check(m.getMaximum(), new Double(3.7));
    harness.check(this.event.getSource(), m);
   
    // same value triggers no event
    this.event = null;
    m.setMaximum(new Double(3.7));
    harness.check(this.event == null);
   
    // set null maximum
    this.event = null;
    m.setMaximum(null);
    harness.check(m.getMaximum(), null);
    harness.check(this.event.getSource(), m);

    // same null value triggers no event
    this.event = null;
    m.setMaximum(null);
    harness.check(this.event == null);
   
    // set maximum lower than minimum
    m.setMaximum(new Double(-99.0));
    harness.check(m.getMaximum(), new Double(-99.0));
  }
View Full Code Here


public class getNextValue implements Testlet {

  public void test(TestHarness harness)
  {
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getNextValue(), new Double(2.5));
   
    // accessing the next value doesn't update the current value
    harness.check(m.getValue(), new Double(2.0));
   
    m.setValue(new Double(2.5));
    harness.check(m.getNextValue(), new Double(3.0));
    m.setValue(new Double(3.0));
    harness.check(m.getNextValue(), null);
   
    // repeat for model without bounds
    m = new SpinnerNumberModel(new Integer(0), null, null, new Integer(1));
    harness.check(m.getValue(), new Integer(0));
    harness.check(m.getNextValue(), new Integer(1));

    // accessing the next value doesn't update the current value
    harness.check(m.getValue(), new Integer(0));
   
    m.setValue(new Integer(99));
    harness.check(m.getNextValue(), new Integer(100));
   
    // what happens for max integer
    m.setValue(new Integer(Integer.MAX_VALUE));
    harness.check(m.getNextValue(), new Integer(Integer.MIN_VALUE));
  }
View Full Code Here

    this.event = e;   
  }
 
  public void test(TestHarness harness)
  {
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    m.addChangeListener(this);
    m.setStepSize(new Double(0.7));
    harness.check(m.getStepSize(), new Double(0.7));
    harness.check(this.event.getSource(), m);
   
    // same value triggers no event
    this.event = null;
    m.setStepSize(new Double(0.7));
    harness.check(this.event == null);
   
    // set null step size
    boolean pass = false;
    try
    {
      m.setStepSize(null);       
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
View Full Code Here

    this.event = e;   
  }
 
  public void test(TestHarness harness)
  {
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    m.addChangeListener(this);
    m.setValue(new Double(2.2));
    harness.check(m.getValue(), new Double(2.2));
    harness.check(this.event.getSource(), m);
   
    // same value triggers no event
    this.event = null;
    m.setValue(new Double(2.2));
    harness.check(this.event == null);
   
    // set value less than minimum
    m.setValue(new Double(-99.0));       
    harness.check(m.getValue(), new Double(-99.0));

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

public class getPreviousValue implements Testlet {


  public void test(TestHarness harness)
  {
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getPreviousValue(), new Double(1.5));
    // accessing the previous value doesn't update the current value
    harness.check(m.getValue(), new Double(2.0));
    m.setValue(new Double(1.5));
    harness.check(m.getPreviousValue(), new Double(1.0));
    m.setValue(new Double(1.0));
    harness.check(m.getPreviousValue(), null);

    // repeat for model without bounds
    m = new SpinnerNumberModel(new Integer(0), null, null, new Integer(1));
    harness.check(m.getValue(), new Integer(0));
    harness.check(m.getPreviousValue(), new Integer(-1));

    // accessing the next value doesn't update the current value
    harness.check(m.getValue(), new Integer(0));
   
    m.setValue(new Integer(-99));
    harness.check(m.getPreviousValue(), new Integer(-100));
   
    // what happens for min integer
    m.setValue(new Integer(Integer.MIN_VALUE));
    harness.check(m.getPreviousValue(), new Integer(Integer.MAX_VALUE))
  }
View Full Code Here

    catch (UnsupportedLookAndFeelException e)
      {
        harness.fail(e.toString())
      }
   
    SpinnerNumberModel m = new SpinnerNumberModel();
    JSpinner spinner = new JSpinner(m);
    harness.check(spinner.getValue(), new Integer(0));
    harness.check(spinner.getEditor() instanceof JSpinner.NumberEditor);
   
    // the model has a listener, but it isn't the spinner, editor or UI
    // some private class is listening and passing on events
    EventListener[] mListeners = m.getListeners(ChangeListener.class);
    harness.check(mListeners.length, 1);
    harness.check(!Arrays.asList(mListeners).contains(spinner));
    harness.check(!Arrays.asList(mListeners).contains(spinner.getUI()));
    harness.check(!Arrays.asList(mListeners).contains(spinner.getEditor()));
  }
View Full Code Here

  }

  public void constructor2(TestHarness harness)
  {
    harness.checkPoint("(SpinnerModel)");
    SpinnerNumberModel m = new SpinnerNumberModel(5, 0, 10, 1);
    JSpinner spinner = new JSpinner(m);
    harness.check(spinner.getValue(), new Integer(5));
    harness.check(spinner.getEditor() instanceof JSpinner.NumberEditor);
   
    // try null model
View Full Code Here

  {
    harness.checkPoint("(JComponent)");
    JSpinner s = new JSpinner();
    s.addPropertyChangeListener(this);
    JComponent e = s.getEditor();
    SpinnerNumberModel m = (SpinnerNumberModel) s.getModel();
   
    EventListener[] l1 = s.getListeners(ChangeListener.class);
    harness.check(Arrays.asList(l1).contains(e));
    harness.check(!Arrays.asList(l1).contains(m));
View Full Code Here

 
  public void test(TestHarness harness)
  {
    harness.checkPoint("()");
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    JSpinner s = new JSpinner(m);
    harness.check(s.getValue(), new Double(2.0));
    harness.check(s.getNextValue(), new Double(2.5));
   
    // accessing the next value doesn't update the current value
View Full Code Here

{
  public void test(TestHarness harness)
  {
    harness.checkPoint("(SpinnerModel)");
    MyJSpinner s1 = new MyJSpinner();
    SpinnerModel m1 = new SpinnerNumberModel();
    JComponent e1 = s1.createEditor(m1);
    harness.check(e1 instanceof JSpinner.NumberEditor);
    // no listeners added to the editor yet
    EventListener[] e1l = e1.getListeners(ChangeListener.class);
    harness.check(e1l.length, 0);
View Full Code Here

TOP

Related Classes of javax.swing.SpinnerNumberModel

Copyright © 2018 www.massapicom. 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.