Java 类javax.swing.SpinnerModel 实例源码

项目:openjdk-jdk10    文件:bug8008657.java   
static void createDateSpinner() {
    Calendar calendar = Calendar.getInstance();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -1);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 1);
    Date latestDate = calendar.getTime();
    SpinnerModel dateModel = new SpinnerDateModel(initDate,
            earliestDate,
            latestDate,
            Calendar.YEAR);
    spinner = new JSpinner();
    spinner.setModel(dateModel);
}
项目:jeffslocker    文件:BackupView.java   
public BackupView() {
    setLayout( new BorderLayout() );
    add( new FormPanel( "backups.jfrm" ), BorderLayout.CENTER );

    SpinnerModel model = new SpinnerNumberModel(30, 1, 120, 1 );
    getSpinner(ID_BACKUP_PERIOD).setModel(model);


    setController( new BackupViewController(this) );
    setUIDirector( new BackupViewUIDirector() );

    model.setValue( AppProperties.getIntProperty( ID_BACKUP_PERIOD, 30 ) );
    setText(ID_BACKUP_LOCATION, AppProperties.getProperty( ID_BACKUP_LOCATION));
    setSelected( ID_AUTOMATIC_BACKUPS, "true".equals(AppProperties.getProperty( ID_AUTOMATIC_BACKUPS)));
    setVisible(ID_BACKUP_MESSAGE, false );
    updateComponents(null);
}
项目:jGAF    文件:PropertiesPanel.java   
/**
* Helper method to create a JSpinner.
* 
* @param range the range of the spinner
* @param dtype data type. One of the DTYPE_XXX constants defined in
* com.korilog.kform.core.Item.
*/
  private JSpinner createSpinner(Range range, int dtype){
      JSpinner     spin;
      SpinnerModel model;

      if (dtype==Item.DTYPE_INT){
          model = new SpinnerNumberModel(
                  ((IntRange)range).getRangeDef(),
                  ((IntRange)range).getRangeFrom(),
                  ((IntRange)range).getRangeTo(),
                  1);
      }
      else{
          model = new SpinnerNumberModel(
                  ((DoubleRange)range).getRangeDef(),
                  ((DoubleRange)range).getRangeFrom(),
                  ((DoubleRange)range).getRangeTo(),
                  1);
      }
      spin= new JSpinner(model);

      return spin;
  }
项目:geoxygene    文件:StyleEditionFrame.java   
/**
 * This method creates and return the panel of the width. It used for the
 * stroke elements and contains the unit panel.
 * 
 * @param width
 *            the width of the stroke of the style to be modified.
 * @param unit
 *            the unit of the style to be modified.
 * @return the panel of the width.
 */
public JPanel createWidthPanel(double width, String unit) {
    JLabel lblWidth = new JLabel(I18N.getString("StyleEditionFrame.Width")); //$NON-NLS-1$

    SpinnerModel model = new SpinnerNumberModel(width, // initial value
            0d, // min
            1000d, // max
            0.5d);
    JSpinner spinner = new JSpinner(model);
    spinner.addChangeListener(this);

    JPanel widthPanel = new JPanel();
    widthPanel.add(lblWidth);
    widthPanel.add(spinner);
    widthPanel.add(this.createUnitPanel(unit));
    return widthPanel;
}
项目:geoxygene    文件:StyleEditionFrame.java   
/**
 * This method creates and return the panel of the size of a point symbol.
 * 
 * @param size
 *            the size of the style to be modified.
 * @return the panel of the size of a point symbol.
 */
public JPanel createSizePanel(float size) {
    JLabel lblSize = new JLabel(I18N.getString("StyleEditionFrame.Size")); //$NON-NLS-1$

    SpinnerModel model = new SpinnerNumberModel(size, // initial value
            0f, // min
            1000f, // max
            0.5f);
    JSpinner spinner = new JSpinner(model);
    spinner.addChangeListener(this);

    JPanel sizePanel = new JPanel();
    sizePanel.add(lblSize);
    sizePanel.add(spinner);

    return sizePanel;
}
项目:geoxygene    文件:PointPanel.java   
/**
 * This method creates and return the panel of the size of a point symbol.
 * 
 * @param size
 *            the size of the style to be modified.
 * @return the panel of the size of a point symbol.
 */
public JPanel createSizePanel(float size) {
    JLabel lblSize = new JLabel(I18N.getString("StyleEditionFrame.Size")); //$NON-NLS-1$

    SpinnerModel model = new SpinnerNumberModel(size, // initial value
            0f, // min
            1000f, // max
            0.5f);
    JSpinner spinner = new JSpinner(model);
    spinner.addChangeListener(this);

    JPanel sizePanel = new JPanel();
    sizePanel.add(lblSize);
    sizePanel.add(spinner);

    return sizePanel;
}
项目:geoxygene    文件:LinePanel.java   
/**
 * This method creates and return the panel of the width. It used for the
 * stroke elements and contains the unit panel.
 * 
 * @param width
 *            the width of the stroke of the style to be modified.
 * @param unit
 *            the unit of the style to be modified.
 * @return the panel of the width.
 */
public JPanel createWidthPanel(double width, String unit) {
    JLabel lblWidth = new JLabel(I18N.getString("StyleEditionFrame.Width")); //$NON-NLS-1$

    SpinnerModel model = new SpinnerNumberModel(width, // initial value
            0d, // min
            1000d, // max
            0.5d);
    JSpinner spinner = new JSpinner(model);
    spinner.addChangeListener(this);

    JPanel widthPanel = new JPanel();
    widthPanel.add(lblWidth);
    widthPanel.add(spinner);
    widthPanel.add(this.createUnitPanel(unit));
    return widthPanel;
}
项目:jeffslocker    文件:BackupView.java   
public BackupView() {
    setLayout( new BorderLayout() );
    add( new FormPanel( "backups.jfrm" ), BorderLayout.CENTER );

    SpinnerModel model = new SpinnerNumberModel(30, 1, 120, 1 );
    getSpinner(ID_BACKUP_PERIOD).setModel(model);


    setController( new BackupViewController(this) );
    setUIDirector( new BackupViewUIDirector() );

    model.setValue( AppProperties.getIntProperty( ID_BACKUP_PERIOD, 30 ) );
    setText(ID_BACKUP_LOCATION, AppProperties.getProperty( ID_BACKUP_LOCATION));
    setSelected( ID_AUTOMATIC_BACKUPS, "true".equals(AppProperties.getProperty( ID_AUTOMATIC_BACKUPS)));
    setVisible(ID_BACKUP_MESSAGE, false );
    updateComponents(null);
}
项目:SWAT20    文件:NumberParamValuePanel.java   
public NumberParamValuePanel(Parameter parameter) {
    super();
    final String type = parameter.getValue().getType();
    final Parameter curParam = parameter;
    SpinnerModel model = new SpinnerNumberModel(1, 0, 100, 1);
    JSpinner spinner = new JSpinner(model);
    mParaValueBox = spinner;

    parameter.setValue(type, Integer.toString(0));

    mParaValueBox.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            //System.out.println("Setting value of parameter to: " + mParaValueBox.getModel().getValue());
            curParam.setValue(type, Integer.toString((Integer) mParaValueBox.getModel().getValue()));

        }
    });

    this.add(mParaValueBox);
}
项目:swingsane    文件:KnownSaneOptions.java   
public static SpinnerModel getBlackThresholdModel(Scanner scanner) {
  SpinnerNumberModel blackThresholdModel = new SpinnerNumberModel(0, MIN_BLACK_THRESHOLD,
      MAX_BLACK_THRESHOLD, 1);

  HashMap<String, FixedOption> fixedOptions = scanner.getFixedOptions();

  FixedOption fixedOption = fixedOptions.get(SANE_NAME_THRESHOLD);

  if (fixedOption == null) {
    return null;
  }

  Constraints constraints = fixedOption.getConstraints();
  Integer maxInt = constraints.getMaximumInteger();
  Integer minInt = constraints.getMinimumInteger();

  blackThresholdModel.setMaximum(maxInt);
  blackThresholdModel.setMinimum(minInt);
  blackThresholdModel.setStepSize(constraints.getQuantumInteger());

  blackThresholdModel.setValue(fixedOption.getValue());

  return blackThresholdModel;
}
项目:MIDI-Automator    文件:GUIAutomationPanel.java   
/**
 * Creates the panel for the global settings.
 */
private void createGlobalSettingsPanel() {

    globalSettingsPanel = new JPanel();
    globalSettingsPanel.setLayout(new FlowLayout());

    JLabel minSimilarityLabel = new JLabel(MIN_SIMILARITY_LABEL);

    SpinnerModel spinnerModel = new SpinnerNumberModel(
            GUIAutomation.DEFAULT_MIN_SIMILARITY,
            GUIAutomation.MIN_SIMILARITY_MIN_VALUE,
            GUIAutomation.MIN_SIMILARITY_MAX_VALUE,
            MIN_SIMILARITY_STEP_SIZE);

    minSimilaritySpinner = new JSpinner(spinnerModel);
    minSimilaritySpinner.setName(NAME_MIN_SIMILARITY_SPINNER);

    globalSettingsPanel.add(minSimilarityLabel);
    globalSettingsPanel.add(minSimilaritySpinner);
}
项目:hipster    文件:XMLPanel.java   
private static JSpinner makeDate(Controller c, String source,
        GridBagLayout gbl, GridBagConstraints con) {
    JSpinner dt = new JSpinner();
    SpinnerModel sm = new SpinnerDateModel();
    dt.setModel(sm);
    JSpinner.DateEditor editor = (JSpinner.DateEditor)dt.getEditor();
    JTextField txt = editor.getTextField();
    txt.setForeground(Color.WHITE);
    txt.setBackground(new Color(55, 55, 55));
    txt.setCaretColor(Color.WHITE);
    gbl.setConstraints(dt, con);
    if (source.startsWith("#")) {
        c.bind(dt, source.substring(1));
    } else {
        dt.setValue(source);
    }
    return dt;
}
项目:BigTweet    文件:AdvancedTab.java   
private void loadComboBoxes() {
        //cargar lista de modelos en jcombobox
    this.comboModel.removeAllItems();
    String modelPreCombo = bt.getSpreadModelName();
    for (String spm : SpreadModel.getListOfModels()) {
        this.comboModel.addItem(spm);
    }
    this.comboModel.setSelectedItem(modelPreCombo);


    //cargar lista de modelos en jcombobox de centrality
    this.comboModel2.removeAllItems();
     this.comboModel2.addItem("betwenness");
     this.comboModel2.addItem("closeness");
     this.comboModel2.addItem("degree");
     this.comboModel2.addItem("random");
    this.comboModel2.setSelectedItem("betwenness");

    SpinnerModel model = new SpinnerNumberModel(10,  1,   bt.getNumUsers(), 1); 
    nagents.setModel(model);
}
项目:Skew    文件:MagnitudeView.java   
@Override
public SpinnerModel scaleSpinnerModel(MapSubView subView)
{
    GrainMagnitudeSubView gms = (GrainMagnitudeSubView)subView;

    float grainVal;
    float maxVal = 0;
    for (Grain g : GrainUtil.getGrains(grainModel))
    {
        grainVal = (float) gms.select(new double[]{g.magMin, g.magMax, g.magAvg});
        maxVal = Math.max(grainVal, maxVal);
    }

    maxVal = (int)(maxVal * 10);
    maxVal /= 10f;
    return new SpinnerNumberModel(maxVal, 0.0, 180.0, 0.1);
}
项目:UiL-OTS-Video-Coding-System    文件:TimeSelector.java   
private SpinnerModel[] getSpinnerModels()
{
    SpinnerModel[] spinnermodel = new SpinnerModel[4];

    long ct = current_time;
    for(int i = 0; i < 4; i++)
    {           
        int max = (int) Math.floor(video_duration / devisions[i]);
        max = max < maxes[i] || max == 0 ? max : maxes[i];
        int cur = 0;
        while(ct > devisions[i])
        {
            ct -= devisions[i];
            cur++;
        }
        spinnermodel[i] = new SpinnerNumberModel(cur,0, max, 1);
    }

    return spinnermodel;
}
项目:UiL-OTS-Video-Coding-System    文件:TimeSelector.java   
private void createElements()
{
    SpinnerModel[] models = getSpinnerModels();

    hour_spinner = new JSpinner(models[0]);
    minute_spinner = new JSpinner(models[1]);
    second_spinner = new JSpinner(models[2]);
    millisecond_spinner = new JSpinner(models[3]);

    lblH = new JLabel("H");
    lblM = new JLabel("M");
    lblS = new JLabel("S");
    lblMs = new JLabel("mS");

    btnGo = new JButton("Go to time");
    btnGo.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e) {
            vc.setMediaTime(getSelectedTime());             
        }

    });
}
项目:KinOathKinshipArchiver    文件:DateEditorPanel.java   
private void addNumberSpinner(final Element svgElement, JPanel sidePanel, String labelString, final String attributeString, int minValue, int maxValue) {
    int initialValue = 0;
    try {
        final String initialValueString = svgElement.getAttribute(attributeString).trim();
        if (initialValueString.length() > 0) {
            initialValue = Integer.decode(initialValueString);
        }
    } catch (NumberFormatException exception) {
        BugCatcherManager.getBugCatcher().logError(exception);
    }
    sidePanel.add(new JLabel(labelString));
    SpinnerModel spinnerModel =
            new SpinnerNumberModel(initialValue, minValue, maxValue, 1);
    final JSpinner numberSpinner = new JSpinner(spinnerModel);
    numberSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            updateValue(svgElement, attributeString, numberSpinner.getValue().toString());
        }
    });
    sidePanel.add(numberSpinner);
}
项目:KinOathKinshipArchiver    文件:SvgElementEditor.java   
private void addNumberSpinner(final Element svgElement, JPanel sidePanel, String labelString, final String attributeString, int minValue, int maxValue) {
    int initialValue = 0;
    try {
        final String initialValueString = svgElement.getAttribute(attributeString).trim();
        if (initialValueString.length() > 0) {
            initialValue = Integer.decode(initialValueString);
        }
    } catch (NumberFormatException exception) {
        BugCatcherManager.getBugCatcher().logError(exception);
    }
    sidePanel.add(new JLabel(labelString));
    SpinnerModel spinnerModel =
            new SpinnerNumberModel(initialValue, minValue, maxValue, 1);
    final JSpinner numberSpinner = new JSpinner(spinnerModel);
    numberSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            updateValue(svgElement, attributeString, numberSpinner.getValue().toString());
        }
    });
    sidePanel.add(numberSpinner);
}
项目:Ic2ExpReactorPlanner    文件:ReactorPlannerFrame.java   
private void clearGridButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearGridButtonActionPerformed
    reactor.clearGrid();
    for (int i = 0; i < reactorButtons.length; i++) {
        for (int j = 0; j < reactorButtons[i].length; j++) {
            reactorButtons[i][j].setIcon(null);
            reactorButtons[i][j].setToolTipText(null);
            reactorButtonPanels[i][j].setBackground(Color.LIGHT_GRAY);
        }
    }
    outputArea.setText(null);
    materialsArea.setText(reactor.getMaterials().toString());
    componentListArea.setText(reactor.getComponentList().toString());
    maxHeatLabel.setText(String.format("/%,.0f", reactor.getMaxHeat()));
    temperatureEffectsLabel.setText(String.format("Burn: %,d  Evaporate: %,d  Hurt: %,d  Lava: %,d  Explode: %,d", (int)(reactor.getMaxHeat() * 0.4), (int)(reactor.getMaxHeat() * 0.5), (int)(reactor.getMaxHeat() * 0.7), (int)(reactor.getMaxHeat() * 0.85), (int)(reactor.getMaxHeat() * 1.0)));
    SpinnerModel model = heatSpinner.getModel();
    if (model instanceof SpinnerNumberModel) {
        ((SpinnerNumberModel) model).setMaximum(reactor.getMaxHeat());
    }
    changingCode = true;
    codeField.setText(null);
    changingCode = false;
}
项目:chipster    文件:IntegerInputComponent.java   
/**
 * Creates a new IntegerInputComponent.
 * 
 * @param param The IntegerParameter to be controlled.
 * @param parameterPanel The ParameterPanel to which this component is to
 *               be placed.
 */
public IntegerInputComponent(
        IntegerParameter param, ParameterPanel parameterPanel) {
    super(parameterPanel);
    this.param = param;
    this.state = ParameterInputComponent.INPUT_IS_INITIALIZED;
    SpinnerModel model = new NullableSpinnerModel();
    model.setValue(param.getValue());
    this.spinner = new JSpinner(model);
    spinner.addFocusListener(this);
    spinner.setPreferredSize(ParameterInputComponent.PREFERRED_SIZE);   

    // The second parameter of NumberEditor constructor is number format
    // The string "0" means that it is a digit without any thousand separators
    // or decimals
    spinner.setEditor(new NullableSpinnerEditor(spinner, "0"));

    spinner.addChangeListener(this);
    field = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();
    field.addCaretListener(this);
       field.setBackground(BG_VALID);
    this.add(spinner, BorderLayout.CENTER);     
}
项目:incubator-netbeans    文件:JExtendedSpinner.java   
public JExtendedSpinner(SpinnerModel model) {
    super(model);
    ((JSpinner.DefaultEditor) getEditor()).getTextField().setFont(UIManager.getFont("Label.font")); // NOI18N
    ((JSpinner.DefaultEditor) getEditor()).getTextField().addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(final java.awt.event.KeyEvent e) {
                if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ESCAPE) {
                    processKeyEvent(e);
                }
            }
        });
    configureWheelListener();
}
项目:incubator-netbeans    文件:JExtendedSpinner.java   
public void setModel(SpinnerModel model) {
    Font font = ((JSpinner.DefaultEditor) getEditor()).getTextField().getFont();
    String accessibleName = ((JSpinner.DefaultEditor) getEditor()).getTextField().getAccessibleContext().getAccessibleName();
    String accessibleDescription = ((JSpinner.DefaultEditor) getEditor()).getTextField().getAccessibleContext()
                                    .getAccessibleDescription();
    super.setModel(model);
    ((JSpinner.DefaultEditor) getEditor()).getTextField().setFont(font);
    ((JSpinner.DefaultEditor) getEditor()).getTextField().getAccessibleContext().setAccessibleName(accessibleName);
    ((JSpinner.DefaultEditor) getEditor()).getTextField().getAccessibleContext()
     .setAccessibleDescription(accessibleDescription);
}
项目:marathonv5    文件:JSpinnerJavaElementTest.java   
private JSpinner createNumberSpinner(Calendar calendar) {
    int currentYear = calendar.get(Calendar.YEAR);
    SpinnerModel yearModel = new SpinnerNumberModel(currentYear, currentYear - 100, currentYear + 100, 1);
    JSpinner numberSpinner = new JSpinner(yearModel);
    numberSpinner.setEditor(new JSpinner.NumberEditor(numberSpinner, "#"));
    numberSpinner.setName("number-spinner");
    return numberSpinner;
}
项目:RxJava2Swing    文件:ChangeEventSpinnerModelObservable.java   
@Override
protected void subscribeActual(Observer<? super ChangeEvent> observer) {
    SpinnerModel w = widget;

    ChangeEventConsumer aec = new ChangeEventConsumer(observer, w);
    observer.onSubscribe(aec);

    w.addChangeListener(aec);
    if (aec.get() == null) {
        aec.onDispose(w);
    }
}
项目:openjdk-jdk10    文件:bug8008657.java   
static void createNumberSpinner() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.YEAR, -1);
    calendar.add(Calendar.YEAR, 1);
    int currentYear = calendar.get(Calendar.YEAR);
    SpinnerModel yearModel = new SpinnerNumberModel(currentYear, //initial value
            currentYear - 1, //min
            currentYear + 2, //max
            1);                //step
    spinner = new JSpinner();
    spinner.setModel(yearModel);
}
项目:openjdk-jdk10    文件:JSpinnerOperator.java   
/**
 * Returns a minimal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a minimal value.
 *
 * @return a minimal value.
 */
public Object getMinimum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMinimum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk-jdk10    文件:JSpinnerOperator.java   
/**
 * Returns a maximal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a maximal value.
 *
 * @return a maximal value.
 */
public Object getMaximum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMaximum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk-jdk10    文件:JSpinnerOperator.java   
/**
 * Maps {@code JSpinner.setModel(SpinnerModel)} through queue
 */
public void setModel(final SpinnerModel spinnerModel) {
    runMapping(new MapVoidAction("setModel") {
        @Override
        public void map() {
            ((JSpinner) getSource()).setModel(spinnerModel);
        }
    });
}
项目:openjdk-jdk10    文件:JSpinnerOperator.java   
/**
 * Maps {@code JSpinner.getModel()} through queue
 */
public SpinnerModel getModel() {
    return (runMapping(new MapAction<SpinnerModel>("getModel") {
        @Override
        public SpinnerModel map() {
            return ((JSpinner) getSource()).getModel();
        }
    }));
}
项目:openjdk9    文件:bug8008657.java   
static void createDateSpinner() {
    Calendar calendar = Calendar.getInstance();
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -1);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 1);
    Date latestDate = calendar.getTime();
    SpinnerModel dateModel = new SpinnerDateModel(initDate,
            earliestDate,
            latestDate,
            Calendar.YEAR);
    spinner = new JSpinner();
    spinner.setModel(dateModel);
}
项目:openjdk9    文件:bug8008657.java   
static void createNumberSpinner() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.YEAR, -1);
    calendar.add(Calendar.YEAR, 1);
    int currentYear = calendar.get(Calendar.YEAR);
    SpinnerModel yearModel = new SpinnerNumberModel(currentYear, //initial value
            currentYear - 1, //min
            currentYear + 2, //max
            1);                //step
    spinner = new JSpinner();
    spinner.setModel(yearModel);
}
项目:openjdk9    文件:JSpinnerOperator.java   
/**
 * Returns a minimal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a minimal value.
 *
 * @return a minimal value.
 */
public Object getMinimum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMinimum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk9    文件:JSpinnerOperator.java   
/**
 * Returns a maximal value. Returns null if model is not one of the
 * following: {@code javax.swing.SpinnerDateModel},
 * {@code javax.swing.SpinnerListModel},
 * {@code javax.swing.SpinnerNumberModel}. Also, returns null if the
 * model does not have a maximal value.
 *
 * @return a maximal value.
 */
public Object getMaximum() {
    SpinnerModel model = getModel();
    if (model instanceof SpinnerNumberModel) {
        return ((SpinnerNumberModel) model).getMaximum();
    } else if (model instanceof SpinnerDateModel) {
        return ((SpinnerDateModel) model).getEnd();
    } else if (model instanceof SpinnerListModel) {
        List<?> list = ((SpinnerListModel) model).getList();
        return list.get(list.size() - 1);
    } else {
        return null;
    }
}
项目:openjdk9    文件:JSpinnerOperator.java   
/**
 * Maps {@code JSpinner.setModel(SpinnerModel)} through queue
 */
public void setModel(final SpinnerModel spinnerModel) {
    runMapping(new MapVoidAction("setModel") {
        @Override
        public void map() {
            ((JSpinner) getSource()).setModel(spinnerModel);
        }
    });
}
项目:openjdk9    文件:JSpinnerOperator.java   
/**
 * Maps {@code JSpinner.getModel()} through queue
 */
public SpinnerModel getModel() {
    return (runMapping(new MapAction<SpinnerModel>("getModel") {
        @Override
        public SpinnerModel map() {
            return ((JSpinner) getSource()).getModel();
        }
    }));
}
项目:audiveris    文件:SpinnerUtil.java   
/**
 * Assign the List model (for a list-based spinner)
 *
 * @param spinner the spinner to update
 * @param values  the model list values
 */
public static void setList (JSpinner spinner,
                            List<?> values)
{
    SpinnerModel model = spinner.getModel();

    if (model instanceof SpinnerListModel) {
        ((SpinnerListModel) model).setList(values);
    } else {
        throw new IllegalArgumentException("Spinner model is not a SpinnerListModel");
    }
}
项目:audiveris    文件:ScoreParameters.java   
public SpinData (String label,
                 String tip,
                 SpinnerModel model)
{
    this.label = new JLabel(label, SwingConstants.RIGHT);

    spinner = new JSpinner(model);
    SpinnerUtil.setRightAlignment(spinner);
    SpinnerUtil.setEditable(spinner, true);
    spinner.setToolTipText(tip);
}
项目:DigitalMediaServer    文件:CustomJSpinner.java   
@Override
protected JComponent createEditor(SpinnerModel model) {
    if (model instanceof SpinnerDateModel) {
        return new DateEditor(this);
    } else if (model instanceof SpinnerNumberModel) {
        return new NumberEditor(this);
    } else if (model instanceof SpinnerListModel) {
        return new ListEditor(this);
    } else if (model instanceof SpinnerIntModel) {
        return new IntegerEditor(this);
    } else {
        return new DefaultEditor(this);
    }
}
项目:netbeansplugins    文件:LocaleDatePanel.java   
/**
 * Set a Date value of the currently active SpinnerModel
 */
private void setDateSpinnerValue(Date date) {
    SpinnerModel sm = this.dateSpinner.getModel();
    if (sm instanceof SpinnerNumberModel) {
        sm.setValue(date.getTime());
    } else if (sm instanceof SpinnerDateModel) {
        sm.setValue(date);
    }
}
项目:netbeansplugins    文件:LocaleDatePanel.java   
/**
 * Get a Date value from the currently active SpinnerModel
 */
private Date getDateSpinnerValue() {
    Date date = new Date();

    SpinnerModel sm = this.dateSpinner.getModel();
    if (sm instanceof SpinnerNumberModel) {
        Long value = (Long) sm.getValue();
        date.setTime(value);
    } else if (sm instanceof SpinnerDateModel) {
        date = (Date) sm.getValue();
    }
    return date;
}