Package javax.swing

Examples of javax.swing.SpinnerNumberModel


  private Label lblInit;
  private Label lblStep;

 
  public void setValue(Object value) {
    SpinnerNumberModel model = (SpinnerNumberModel) value;
    Comparable max = model.getMaximum();
    Comparable min = model.getMinimum();
    Number number = model.getNumber();
    Number size = model.getStepSize();
    if (max == null && min == null && number instanceof Integer && size instanceof Integer && number.intValue() == 0 && size.intValue() == 1)
      btnDefault.setSelection(true);
    else {
      btnDefault.setSelection(false);
      int index = NumberType.getNumberTypeIndex(number);
View Full Code Here


  }

 
  public Object getValue() {
    if (btnDefault.getSelection())
      return new SpinnerNumberModel();
    else {
      int index = cmbType.getSelectionIndex();
      NumberType type = NumberType.getTypes()[index];
      Number init = type.valueOf(spInit.getSelection());
      Number min = null;
      if (btnMin.getSelection()) {
        min = type.valueOf(spMin.getSelection());
      }
      Number max = null;
      if (btnMax.getSelection()) {
        max = type.valueOf(spMax.getSelection());
      }
      Number size = type.valueOf(spStep.getSelection());
      return new SpinnerNumberModel(init, (Comparable) min, (Comparable) max, size);
    }
  }
View Full Code Here

  }

 
  public String getJavaCode(Object value, ImportRewrite imports) {
    String className = imports.addImport("javax.swing.SpinnerNumberModel");
    SpinnerNumberModel snm = (SpinnerNumberModel) value;
    Number init = snm.getNumber();
    Comparable<?> max = snm.getMaximum();
    Comparable<?> min = snm.getMinimum();
    Number step = snm.getStepSize();
    if (min == null && max == null && init instanceof Integer && step instanceof Integer) {
      return "new " + className + "()";
    }
    if (init instanceof Integer && step instanceof Integer) {
      return "new " + className + "(" + init + ", " + min + ", " + max + ", " + step + ")";
View Full Code Here

        + typeCode + ".valueOf(" + step + "))";
  }

 
  public int compare(SpinnerModel o1, SpinnerModel o2) {
    SpinnerNumberModel snm1 = (SpinnerNumberModel) o1;
    SpinnerNumberModel snm2 = (SpinnerNumberModel) o2;
    Number value1 = snm1.getNumber();
    Number value2 = snm2.getNumber();
    if(!value1.equals(value2))
      return 1;
    Comparable min1 = snm1.getMinimum();
    Comparable min2 = snm2.getMinimum();
    if(!equals(min1, min2))
      return 1;
    Comparable max1 = snm1.getMaximum();
    Comparable max2 = snm2.getMaximum();
    if(!equals(max1, max2))
      return 1;
    Number step1 = snm1.getStepSize();
    Number step2 = snm2.getStepSize();
    if(!step1.equals(step2))
      return 1;
    return 0;
  }
View Full Code Here

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                final Device dev = UserFacade.getInstance().getSelectedDevice();

                final JDialog dlg = new JDialog((Dialog) null, "create new partition", true);
                final SpinnerNumberModel spn = new SpinnerNumberModel(10, 1, dev.getSize(), 10);
                dlg.getContentPane().setLayout(new FlowLayout());
                dlg.getContentPane().add(new JLabel("size : "));
                dlg.getContentPane().add(new JSpinner(spn));
                JButton btn = new JButton("Add partition");
                btn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        long size = spn.getNumber().longValue();
                        try {
                            UserFacade.getInstance().createPartition(
                                    view.getPartition().getStart(), size);
                        } catch (Exception e1) {
                            errorReporter.reportError(log, AddPartitionAction.this, e1);
View Full Code Here

    setTitle(UtilMessages.getInstance().getString("GuideLineDialog.Position"));
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setModal(true);

    positionSpinner = new JSpinner(new SpinnerNumberModel(ZERO, ZERO, null, ONE));
    unitModel = createUnitModel();

    return createSelectionPane();
  }
View Full Code Here

    setTitle(UtilMessages.getInstance().getString("GridSizeDialog.Title"));
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setModal(true);

    gridSizeSpinner = new JSpinner(new SpinnerNumberModel(ZERO, ZERO, null, STEP_SIZE));
    unitModel = createUnitModel();
    gridDivisionSpinner = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1));

    super.init();
  }
View Full Code Here

    colorSelectorBox.addActionListener(updateHandler);

    minimumWidth = new JTextField();
    minimumHeight = new JTextField();

    paddingTop = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));
    paddingLeft = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));
    paddingBottom = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));
    paddingRight = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));

    cornerWidth = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));
    cornerWidth.addChangeListener(updateHandler);
    cornerHeight = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));
    cornerHeight.addChangeListener(updateHandler);

    borderEditorPanel = new BorderRenderPanel();
    borderEditorPanel.setMinimumSize(new Dimension(100, 100));
    borderEditorPanel.setPreferredSize(new Dimension(250, 250));
    borderEditorPanel.setMaximumSize(new Dimension(250, 250));
    borderEditorPanel.getSelectionModel().addBorderSelectionListener(new BorderSelectionUpdateHandler());

    borderWidth = new JSpinner(new SpinnerNumberModel(0, 0, Short.MAX_VALUE, 1));
    borderWidth.addChangeListener(updateHandler);

    final JPanel borderCornerCarrier = new JPanel(new GridBagLayout());
    borderCornerCarrier.setBorder(BorderFactory.createTitledBorder(Messages.getString("BorderPropertiesPane.RoundedCorners")));
View Full Code Here

    urlCombo = new JComboBox(urlModel);

    userField = new JTextField(25);
    userPasswordField = new JPasswordField();

    final SpinnerNumberModel spinnerModel = new SpinnerNumberModel();
    spinnerModel.setMinimum(0);
    spinnerModel.setMaximum(99999);

    timeoutField = new JSpinner(spinnerModel);
    timeoutField.setEditor(new JSpinner.NumberEditor(timeoutField, "#####"));

    rememberSettings = new JCheckBox(Messages.getInstance().getString("RepositoryLoginDialog.RememberTheseSettings"), true);
View Full Code Here

    init();
  }

  protected void init()
  {
    dataRowsField = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1));
    headerRowsField = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1));
    colsField = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1));

    setTitle("Insert Table ..");
    super.init();
  }
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.