List of utility methods to do JSpinner
void | reattachChangeListeners(JSpinner spinner, ChangeListener[] listeners) reattach Change Listeners for (ChangeListener listener : listeners) {
spinner.addChangeListener(listener);
|
void | replaceSpinnerValue(JSpinner spinner, double value) replace Spinner Value ChangeListener[] listeners = detachChangeListeners(spinner); spinner.setValue(value); reattachChangeListeners(spinner, listeners); |
void | setList(JSpinner spinner, List> values) Assign the List model (for a list-based spinner) SpinnerModel model = spinner.getModel(); if (model instanceof SpinnerListModel) { ((SpinnerListModel) model).setList(values); } else { throw new IllegalArgumentException("Spinner model is not a SpinnerListModel"); |
void | setRightAlignment(JSpinner spinner) Align the spinner display to the right JSpinner.DefaultEditor editor; editor = (JSpinner.DefaultEditor) spinner.getEditor(); editor.getTextField().setHorizontalAlignment(JTextField.RIGHT); |
void | setSpinnerFloatValue(JSpinner sp, float f) Utility function to write to the spinner value. try { sp.setValue((Double) ((double) f)); } catch (Exception ex) { sp.setValue((Float) f); |
void | setSpinnerValue(JSpinner spinner, Integer i) set Spinner Value if (i == null) { spinner.setValue(-1); } else { spinner.setValue(i); |