Package javax.swing

Examples of javax.swing.SpinnerNumberModel


    valueTypeComboBox.setRenderer(new ClassListCellRenderer());
    valueTypeComboBox.getModel().addListDataListener(typeSelectionHandler);

    visibleItemsLabel = new JLabel(Messages.getString("ParameterDialog.VisibleItems"));

    visibleItemsTextField = new JSpinner(new SpinnerNumberModel(0, 0, 50000, 1));

    displayFormulaLabel = new JLabel(Messages.getString("ParameterDialog.DisplayFormula"));

    displayFormulaField = new FormulaEditorPanel();
    displayFormulaField.setEditorDataModel(this);
View Full Code Here


    bg.add(valueSelector);
    bg.add(redSelector);
    bg.add(greenSelector);
    bg.add(blueSelector);

    hue = new JSpinner(new SpinnerNumberModel(0, 0, 359, 1));
    hue.addChangeListener(new HSBKeyboardInputHandler());
    saturation = new JSpinner(new SpinnerNumberModel(0, 0, 100, 1));
    saturation.addChangeListener(new HSBKeyboardInputHandler());
    value = new JSpinner(new SpinnerNumberModel(0, 0, 100, 1));
    value.addChangeListener(new HSBKeyboardInputHandler());

    red = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1));
    red.addChangeListener(new RGBKeyboardInputHandler());
    green = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1));
    green.addChangeListener(new RGBKeyboardInputHandler());
    blue = new JSpinner(new SpinnerNumberModel(0, 0, 255, 1));
    blue.addChangeListener(new RGBKeyboardInputHandler());

    colorCode = new JTextField();
    colorCode.setColumns(6);
    colorCode.getDocument().addDocumentListener(new ColorCodeInputHandler());
View Full Code Here

    dialogModel = new NamedDataSourceDialogModel();
    dialogModel.getQueries().addListDataListener(updateHandler);
    dialogModel.addPropertyChangeListener(confirmAction);

    maxPreviewRowsSpinner = new JSpinner(new SpinnerNumberModel(10000, 1, Integer.MAX_VALUE, 1));

    cubeConnectionNameField = new JTextField(null, 0);
    cubeConnectionNameField.setColumns(30);
    cubeConnectionNameField.getDocument().addDocumentListener(confirmAction);
View Full Code Here

    JFormattedTextField ftf = e.getTextField();
    NumberFormatter nf = (NumberFormatter) ftf.getFormatter();
    harness.check(nf.getMinimum(), null);
    harness.check(nf.getMaximum(), null);
   
    SpinnerNumberModel m = new SpinnerNumberModel(50.0, 0.0, 100.0, 5.0);
    s = new JSpinner(m);
    e = new JSpinner.NumberEditor(s);
    harness.check(e.getFormat(), NumberFormat.getInstance());
    ftf = e.getTextField();
    nf = (NumberFormatter) ftf.getFormatter();
View Full Code Here

{

  public void test(TestHarness harness)
  {
    harness.checkPoint("()");
    SpinnerNumberModel m = new SpinnerNumberModel(50.0, 0.0, 100.0, 5.0);
    JSpinner s = new JSpinner(m);
    JSpinner.NumberEditor editor = (JSpinner.NumberEditor) s.getEditor();
    harness.check(editor.getModel(), m);
  }
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.setMinimum(new Double(0.7));
    harness.check(m.getMinimum(), new Double(0.7));
    harness.check(this.event.getSource(), m);
   
    // same value triggers no event
    this.event = null;
    m.setMinimum(new Double(0.7));
    harness.check(this.event == null);
   
    // set null minimum
    this.event = null;
    m.setMinimum(null);
    harness.check(m.getMinimum(), null);
    harness.check(this.event.getSource(), m);

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

  }

  private void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("()");
    SpinnerNumberModel m = new SpinnerNumberModel();
    harness.check(m.getValue(), new Integer(0));
    harness.check(m.getMinimum(), null);
    harness.check(m.getMaximum(), null);
    harness.check(m.getStepSize(), new Integer(1));
  }
View Full Code Here

  }

  private void testConstructor2(TestHarness harness
  {
    harness.checkPoint("(double, double, double, double)");
    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.5));
   
    // value equal to minimum
    m = new SpinnerNumberModel(1.0, 1.0, 3.0, 0.5);
    harness.check(m.getValue(), new Double(1.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.5));

    // value below minimum
    boolean pass = false;
    try
    {
      m = new SpinnerNumberModel(0.9, 1.0, 3.0, 0.5);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // value equal to maximum
    m = new SpinnerNumberModel(3.0, 1.0, 3.0, 0.5);
    harness.check(m.getValue(), new Double(3.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.5));
   
    // value above maximum
    pass = false;
    try
    {
      m = new SpinnerNumberModel(3.1, 1.0, 3.0, 0.5);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // step size 0
    m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.0);
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.0));
   
    // step size negative
    m = new SpinnerNumberModel(2.0, 1.0, 3.0, -0.5);
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(-0.5));
   
  }
View Full Code Here

  }
 
  private void testConstructor3(TestHarness harness)
  {
    harness.checkPoint("(int, int, int, int)");
    SpinnerNumberModel m = new SpinnerNumberModel(20, 10, 30, 5);
    harness.check(m.getValue(), new Integer(20));
    harness.check(m.getMinimum(), new Integer(10));
    harness.check(m.getMaximum(), new Integer(30));
    harness.check(m.getStepSize(), new Integer(5));

    // value equal to minimum
    m = new SpinnerNumberModel(10, 10, 30, 5);
    harness.check(m.getValue(), new Integer(10));
    harness.check(m.getMinimum(), new Integer(10));
    harness.check(m.getMaximum(), new Integer(30));
    harness.check(m.getStepSize(), new Integer(5));

    // value below minimum
    boolean pass = false;
    try
    {
      m = new SpinnerNumberModel(9, 10, 30, 5);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // value equal to maximum
    m = new SpinnerNumberModel(30, 10, 30, 5);
    harness.check(m.getValue(), new Integer(30));
    harness.check(m.getMinimum(), new Integer(10));
    harness.check(m.getMaximum(), new Integer(30));
    harness.check(m.getStepSize(), new Integer(5));
   
    // value above maximum
    pass = false;
    try
    {
      m = new SpinnerNumberModel(31, 10, 30, 5);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // step size 0
    m = new SpinnerNumberModel(20, 10, 30, 0);
    harness.check(m.getValue(), new Integer(20));
    harness.check(m.getMinimum(), new Integer(10));
    harness.check(m.getMaximum(), new Integer(30));
    harness.check(m.getStepSize(), new Integer(0));
   
    // step size negative
    m = new SpinnerNumberModel(20, 10, 30, -5);
    harness.check(m.getValue(), new Integer(20));
    harness.check(m.getMinimum(), new Integer(10));
    harness.check(m.getMaximum(), new Integer(30));
    harness.check(m.getStepSize(), new Integer(-5));

  }
View Full Code Here

  }
 
  private void testConstructor4(TestHarness harness
  {
    harness.checkPoint("Number, Comparable, Comparable, Number");
    SpinnerNumberModel m = new SpinnerNumberModel(new Long(20), new Long(10),
            new Long(30), new Long(5));
    harness.check(m.getValue(), new Long(20));
    harness.check(m.getMinimum(), new Long(10));
    harness.check(m.getMaximum(), new Long(30));
    harness.check(m.getStepSize(), new Long(5));
   
    // value equal to minimum
    m = new SpinnerNumberModel(new Double(1.0), new Double(1.0),
            new Double(3.0), new Double(0.5));
    harness.check(m.getValue(), new Double(1.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.5));

    // value below minimum
    boolean pass = false;
    try
    {
      m = new SpinnerNumberModel(new Double(0.9), new Double(1.0),
              new Double(3.0), new Double(0.5));
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // value equal to maximum
    m = new SpinnerNumberModel(new Double(3.0), new Double(1.0),
            new Double(3.0), new Double(0.5));
    harness.check(m.getValue(), new Double(3.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.5));
   
    // value above maximum
    pass = false;
    try
    {
      m = new SpinnerNumberModel(new Double(3.1), new Double(1.0),
              new Double(3.0), new Double(0.5));
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // step size 0
    m = new SpinnerNumberModel(new Double(2.0), new Double(1.0),
            new Double(3.0), new Double(0.0));
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(0.0));
   
    // step size negative
    m = new SpinnerNumberModel(new Double(2.0), new Double(1.0),
            new Double(3.0), new Double(-0.5));
    harness.check(m.getValue(), new Double(2.0));
    harness.check(m.getMinimum(), new Double(1.0));
    harness.check(m.getMaximum(), new Double(3.0));
    harness.check(m.getStepSize(), new Double(-0.5));
   
    // check null value
    pass = false;
    try
    {
      /*SpinnerNumberModel m =*/ new SpinnerNumberModel(null, new Long(10),
            new Long(30), new Long(5));
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);

    // check null minimum
   
    // check null maximum
   
    // check null step size
    pass = false;
    try
    {
      /*SpinnerNumberModel m =*/ new SpinnerNumberModel(new Long(20),
              new Long(10), new Long(30), null);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
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.