javax.swing.SpinnerModel Java Examples
The following examples show how to use
javax.swing.SpinnerModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DocumentsPanelProvider.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void openIndex(LukeState state) { documentsModel = documentsFactory.newInstance(state.getIndexReader()); addDocBtn.setEnabled(!state.readOnly() && state.hasDirectoryReader()); int maxDoc = documentsModel.getMaxDoc(); maxDocsLbl.setText("in " + maxDoc + " docs"); if (maxDoc > 0) { int max = Math.max(maxDoc - 1, 0); SpinnerModel spinnerModel = new SpinnerNumberModel(0, 0, max, 1); docNumSpnr.setModel(spinnerModel); docNumSpnr.setEnabled(true); displayDoc(0); } else { docNumSpnr.setEnabled(false); } documentsModel.getFieldNames().stream().sorted().forEach(fieldsCombo::addItem); }
Example #2
Source File: IntegerInputComponent.java From chipster with MIT License | 6 votes |
/** * 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); }
Example #3
Source File: KnownSaneOptions.java From swingsane with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: OptionsPanel.java From wpcleaner with Apache License 2.0 | 6 votes |
/** * Restore all integer options to their default values. */ private void defaultValuesInteger() { for (Entry<ConfigurationValueInteger, Object> entry : integerValues.entrySet()) { if ((entry.getValue() != null) && (entry.getKey() != null)) { if (entry.getValue() instanceof JSpinner) { JSpinner spinner = (JSpinner) entry.getValue(); SpinnerModel model = spinner.getModel(); model.setValue(Integer.valueOf(entry.getKey().getDefaultValue())); } if (entry.getValue() instanceof ButtonGroup) { ButtonGroup group = (ButtonGroup) entry.getValue(); setButtonGroupSelection(group, entry.getKey().getDefaultValue()); } } } }
Example #5
Source File: JExtendedSpinner.java From visualvm with GNU General Public License v2.0 | 5 votes |
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); }
Example #6
Source File: ArrayInspector.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Creates the GUI. */ protected void createGUI() { setSize(400, 300); setContentPane(new JPanel(new BorderLayout())); scrollpane = new JScrollPane(tables[0]); if(tables.length>1) { // create spinner SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1); spinner = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner); editor.getTextField().setFont(tables[0].getFont()); spinner.setEditor(editor); spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int i = ((Integer) spinner.getValue()).intValue(); scrollpane.setViewportView(tables[i]); } }); Dimension dim = spinner.getMinimumSize(); spinner.setMaximumSize(dim); getContentPane().add(scrollpane, BorderLayout.CENTER); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); toolbar.add(new JLabel(" index ")); //$NON-NLS-1$ toolbar.add(spinner); toolbar.add(Box.createHorizontalGlue()); getContentPane().add(toolbar, BorderLayout.NORTH); } else { scrollpane.createHorizontalScrollBar(); getContentPane().add(scrollpane, BorderLayout.CENTER); } }
Example #7
Source File: LengthSpinner.java From pumpernickel with MIT License | 5 votes |
/** * Sets the spinner model. If the argument is not a * <code>LengthSpinnerModel</code> then an * <code>IllegalArgumentException</code> is thrown. */ @Override public void setModel(SpinnerModel c) { if (getModel() instanceof LengthSpinnerModel && (c instanceof LengthSpinnerModel) == false) throw new IllegalArgumentException( "LengthSpinner.setModel() can only be called for LengthSpinnerModels (" + c.getClass().getName() + ")"); super.setModel(c); }
Example #8
Source File: GenericPanelBuilder.java From Ardulink-2 with Apache License 2.0 | 5 votes |
private static SpinnerModel createModel(ConfigAttribute attribute) { ValidationInfo info = attribute.getValidationInfo(); if (info instanceof NumberValidationInfo) { NumberValidationInfo nInfo = (NumberValidationInfo) info; if (wrap(attribute.getType()).equals(Integer.class)) { return new SpinnerNumberModel((int) nInfo.min(), (int) nInfo.min(), (int) nInfo.max(), 1); } return new SpinnerNumberModel(nInfo.min(), nInfo.min(), nInfo.max(), 1); } return new SpinnerNumberModel(); }
Example #9
Source File: ComponentController.java From swingsane with Apache License 2.0 | 5 votes |
private void updateBlackThresholdModel(SpinnerModel blackThresholdSpinnerModel) { JSpinner blackThresholdSpinner = components.getBlackThresholdSpinner(); blackThresholdSpinner.setModel(blackThresholdSpinnerModel != null ? blackThresholdSpinnerModel : new SpinnerNumberModel(1, 1, null, 1)); blackThresholdSpinner.setEnabled(blackThresholdSpinnerModel != null ? !(components .getDefaultThresholdCheckBox().isSelected()) : false); }
Example #10
Source File: ManualScriptPanel.java From EchoSim with Apache License 2.0 | 5 votes |
private void doNewApplication() { if (mRuntime.getApp().getUtterances().size() > 0) { int numIntents = mRuntime.getApp().getUtterances().size(); SpinnerModel sm = new SpinnerNumberModel(numIntents/2, 1, numIntents, Math.max(numIntents/10, 1)); mNumberOfTests.setModel(sm); } }
Example #11
Source File: SampleAnalysisWorkflowManagerIDTIMS.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * */ public void initSampleAliquots() { aliquotName_text.setDocument( new UnDoAbleDocument(aliquotName_text, true)); aliquotName_text.setText("Aliquot Name"); aliquotList = new ArrayList<>(); if (mySample.getFractions().size() > 0) { for (int i = 0; i < mySample.getAliquots().size(); i++) { // only show aliquots with fractions because removed aliquots still exist with zero fraction if (((UPbReduxAliquot) mySample.getAliquots().get(i)).getAliquotFractions().size() > 0) { aliquotList.add(mySample.getAliquots().get(i).getAliquotName()); } } } String[] aliquotArray = new String[aliquotList.size()]; aliquotArray = aliquotList.toArray(aliquotArray); aliquotsList_jList.setListData(aliquotArray); aliquotsList_jList.addListSelectionListener(new AliquotListSelectionListener()); if (aliquotList.size() > 1) { aliquotsList_jList.setSelectedIndex(1); } else { aliquotsList_jList.setSelectedIndex(0); } SpinnerModel valueDigits_spinnerModel = new SpinnerNumberModel(1, 1, 20, 1); insertFractionCount_spinner.setModel(valueDigits_spinnerModel); }
Example #12
Source File: SampleAnalysisWorkflowManagerLAICPMS.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * */ public void initSampleAliquots() { aliquotName_text.setDocument( new UnDoAbleDocument(aliquotName_text, true)); aliquotName_text.setText("Aliquot Name"); aliquotList = new ArrayList<>(); if (mySample.getFractions().size() > 0) { for (int i = 0; i < mySample.getAliquots().size(); i++) { // only show aliquots with fractions because removed aliquots still exist with zero fraction if (((UPbReduxAliquot) mySample.getAliquots().get(i)).getAliquotFractions().size() > 0) { aliquotList.add(mySample.getAliquots().get(i).getAliquotName()); } } } String[] aliquotArray = new String[aliquotList.size()]; aliquotArray = aliquotList.toArray(aliquotArray); aliquotsList_jList.setListData(aliquotArray); // aliquotsList_jList.setListData((String[]) aliquotList.toArray()); aliquotsList_jList.addListSelectionListener(new AliquotListSelectionListener()); if (aliquotList.size() > 1) { aliquotsList_jList.setSelectedIndex(1); } else { aliquotsList_jList.setSelectedIndex(0); } SpinnerModel valueDigits_spinnerModel = new SpinnerNumberModel(1, 1, 20, 1); insertFractionCount_spinner.setModel(valueDigits_spinnerModel); }
Example #13
Source File: AnalyzeAndForwardToolPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
private void StepIntervalSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_StepIntervalSpinnerStateChanged // TODO add your handling code here: SpinnerModel stepModel = StepIntervalSpinner.getModel(); int newStepInterval = (Integer) stepModel.getValue(); //System.out.println("New step = "+newStepInterval); ((AnalyzeToolModel)toolModel).setAnalysisStepInterval(newStepInterval); }
Example #14
Source File: NeuriteTracerResultsDialog.java From SNT with GNU General Public License v3.0 | 5 votes |
private JPanel tracingPanel() { final JPanel tracingOptionsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); useSnapWindow = new JCheckBox("Enable cursor [s]napping within: XY", plugin.snapCursor); useSnapWindow.setBorder(new EmptyBorder(0, 0, 0, 0)); useSnapWindow.addItemListener(this); tracingOptionsPanel.add(useSnapWindow); final SpinnerModel xy_model = new SpinnerNumberModel(plugin.cursorSnapWindowXY * 2, SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_XY, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_XY * 2, 2); snapWindowXYsizeSpinner = new JSpinner(xy_model); ((DefaultEditor) snapWindowXYsizeSpinner.getEditor()).getTextField().setEditable(false); snapWindowXYsizeSpinner.addChangeListener(this); tracingOptionsPanel.add(snapWindowXYsizeSpinner); final JLabel z_spinner_label = leftAlignedLabel("Z", isStackAvailable()); z_spinner_label.setBorder(new EmptyBorder(0, 2, 0, 0)); tracingOptionsPanel.add(z_spinner_label); final SpinnerModel z_model = new SpinnerNumberModel(plugin.cursorSnapWindowZ * 2, SimpleNeuriteTracer.MIN_SNAP_CURSOR_WINDOW_Z, SimpleNeuriteTracer.MAX_SNAP_CURSOR_WINDOW_Z * 2, 2); snapWindowZsizeSpinner = new JSpinner(z_model); ((DefaultEditor) snapWindowZsizeSpinner.getEditor()).getTextField().setEditable(false); snapWindowZsizeSpinner.addChangeListener(this); snapWindowZsizeSpinner.setEnabled(isStackAvailable()); tracingOptionsPanel.add(snapWindowZsizeSpinner); // tracingOptionsPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); return tracingOptionsPanel; }
Example #15
Source File: NoGroupingSpinner.java From microba with BSD 3-Clause "New" or "Revised" License | 5 votes |
public NoGroupingNumberEditor(JSpinner spinner, SpinnerModel model) { super(spinner); JFormattedTextField ftf = (JFormattedTextField) this .getComponent(0); NumberFormat fmt = NumberFormat.getIntegerInstance(); fmt.setGroupingUsed(false); ftf.setFormatterFactory(new DefaultFormatterFactory( new NumberFormatter(fmt))); revalidate(); }
Example #16
Source File: SpinnerUtil.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
/** * 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"); } }
Example #17
Source File: ScoreParameters.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
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); }
Example #18
Source File: FastCopyMainForm.java From FastCopy with Apache License 2.0 | 5 votes |
public void updateAndSavePreferences() { //save the settings Dimension d = frame.getSize(); UserPreference.getInstance().setDimensionX(d.width); UserPreference.getInstance().setDimensionY(d.height); SpinnerModel spinnerModel = fldFontSize.getModel(); int newFontSize = (Integer) spinnerModel.getValue(); UserPreference.getInstance().setFontSize(newFontSize); UserPreference.getInstance().saveSettingsToFile(); }
Example #19
Source File: ArrayPanel.java From osp with GNU General Public License v3.0 | 5 votes |
/** * Creates the GUI. */ protected void createGUI() { this.removeAll(); // remove old elements Paco: be careful with this. If you use the ArrayPanel as a normal JPanel // and have added another component, it will be lost! this.setPreferredSize(new Dimension(400, 300)); this.setLayout(new BorderLayout()); scrollpane = new JScrollPane(tables[0]); if(tables.length>1) { // create spinner SpinnerModel model = new SpinnerNumberModel(0, 0, tables.length-1, 1); spinner = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner); editor.getTextField().setFont(tables[0].indexRenderer.getFont()); spinner.setEditor(editor); spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int i = ((Integer) spinner.getValue()).intValue(); scrollpane.setViewportView(tables[i]); } }); Dimension dim = spinner.getMinimumSize(); spinner.setMaximumSize(dim); add(scrollpane, BorderLayout.CENTER); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); toolbar.add(new JLabel(" index ")); //$NON-NLS-1$ toolbar.add(spinner); toolbar.add(Box.createHorizontalGlue()); add(toolbar, BorderLayout.NORTH); } else { scrollpane.createHorizontalScrollBar(); add(scrollpane, BorderLayout.CENTER); } this.validate(); // refresh the display }
Example #20
Source File: CustomClientResizingProfilePanel.java From plugins with GNU General Public License v3.0 | 5 votes |
private JSpinner createSpinner(int value) { SpinnerModel model = new SpinnerNumberModel(value, Integer.MIN_VALUE, Integer.MAX_VALUE, 1); JSpinner spinner = new JSpinner(model); Component editor = spinner.getEditor(); JFormattedTextField spinnerTextField = ((JSpinner.DefaultEditor) editor).getTextField(); spinnerTextField.setColumns(4); return spinner; }
Example #21
Source File: JSpinnerOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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); } }); }
Example #22
Source File: JSpinnerJavaElementTest.java From marathonv5 with Apache License 2.0 | 5 votes |
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; }
Example #23
Source File: JExtendedSpinner.java From netbeans with Apache License 2.0 | 5 votes |
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(); }
Example #24
Source File: JExtendedSpinner.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example #25
Source File: bug8008657.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example #26
Source File: bug8008657.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example #27
Source File: JSpinnerOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #28
Source File: JSpinnerOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example #29
Source File: JExtendedSpinner.java From visualvm with GNU General Public License v2.0 | 5 votes |
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(); }
Example #30
Source File: JSpinnerOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JSpinner.getModel()} through queue */ public SpinnerModel getModel() { return (runMapping(new MapAction<SpinnerModel>("getModel") { @Override public SpinnerModel map() { return ((JSpinner) getSource()).getModel(); } })); }