List of utility methods to do JSpinner
float | getFloat(JSpinner spinner) get Float float rv = 0; Object o = spinner.getValue(); if (o != null) { if (o instanceof Number) { rv = ((Number) o).floatValue(); return rv; ... |
int | getInt(JSpinner spinner) get Int int rv = 0; Object o = spinner.getValue(); if (o != null) { if (o instanceof Number) { rv = ((Number) o).intValue(); return rv; ... |
int | getInt(SpinnerNumberModel model) get Int return (int) model.getValue(); |
JSpinner | getOnlySpinner(Container owner) get Only Spinner return (JSpinner) getOnlyComponent(owner, JSpinner.class); |
float | getSpinnerFloatValue(JSpinner sp) Utility function to access the spinner value. float f; try { f = (float) ((Double) sp.getValue()).doubleValue(); } catch (Exception ex) { f = ((Float) sp.getValue()).floatValue(); return f; |
DefaultFormatter | getSpinnerFormatter(JSpinner spinner) get Spinner Formatter JComponent comp = spinner.getEditor();
JFormattedTextField field = (JFormattedTextField) comp.getComponent(0);
return (DefaultFormatter) field.getFormatter();
|
int | getSpinnerInt(JSpinner aSpinner) Gets the currently selected integer value in a spinner control. return ((SpinnerNumberModel) aSpinner.getModel()).getNumber().intValue();
|
int | getSpinnerIntValue(final JSpinner spinner) get Spinner Int Value if (spinner == null || spinner.getModel() == null) { return 1; int value = Integer.valueOf(spinner.getModel().getValue().toString()); try { value = NumberFormat.getIntegerInstance() .parse(((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getText()).intValue(); } catch (NumberFormatException e) { ... |
int | getSpinnerIntValue(JSpinner spin) Evaluates the numeric int value of a spinner object return getSpinnerDoubleValue(spin).intValue();
|
void | installSpinnerBugWorkaround(final JSpinner spinner) Installs a workaround for bug #4699955 in a JSpinner. ((DefaultEditor) spinner.getEditor()).getTextField().addFocusListener(new FocusAdapter() { @Override public void focusGained(final FocusEvent e) { if (e.getSource() instanceof JTextComponent) { final JTextComponent text = ((JTextComponent) e.getSource()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ... |