List of utility methods to do JSpinner
void | adjustWithoutNotifyingListeners(JSpinner spinner, double value) adjust Without Notifying Listeners ChangeListener[] cl = spinner.getChangeListeners(); if (cl != null) { for (ChangeListener x : cl) spinner.removeChangeListener(x); ((SpinnerNumberModel) spinner.getModel()).setValue(new Double(value)); if (cl != null) { for (ChangeListener x : cl) ... |
void | ajustarValorCambiador(JSpinner spnActual, int valor) ajustar Valor Cambiador ChangeListener[] lista = spnActual.getChangeListeners(); spnActual.removeChangeListener(lista[0]); spnActual.setValue(valor); spnActual.addChangeListener(lista[0]); |
JSpinner | createSpinner() create Spinner return new JSpinner(); |
JSpinner | createSpinner(SpinnerModel model) create Spinner JSpinner result = new JSpinner(model); return result; |
Box | createSpinnerForm(String label, JSpinner spinner) create Spinner Form Box panel = Box.createHorizontalBox(); panel.add(Box.createHorizontalGlue()); panel.add(new JLabel(label)); panel.add(Box.createHorizontalGlue()); panel.add(spinner); return panel; |
void | dereferenceSpinnerNumberModel(SpinnerNumberModel model) dereference Spinner Number Model for (ChangeListener listener : model.getChangeListeners()) {
model.removeChangeListener(listener);
|
ChangeListener[] | detachChangeListeners(JSpinner spinner) detach Change Listeners ChangeListener[] listeners = spinner.getChangeListeners(); for (ChangeListener listener : listeners) { spinner.removeChangeListener(listener); return listeners; |
void | fixIntegerList(final JSpinner spinner) Workaround for a swing bug : when the user enters an illegal value, the text is forced to the last value. JSpinner.DefaultEditor editor; editor = (JSpinner.DefaultEditor) spinner.getEditor(); final JFormattedTextField ftf = editor.getTextField(); ftf.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "enterAction"); ftf.getActionMap().put("enterAction", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { ... |
void | formatSpinner(JSpinner spinner, String format) format Spinner JComponent editor = spinner.getEditor(); Dimension preferredSize = null; if (editor instanceof JSpinner.NumberEditor) { JSpinner.NumberEditor numberEditor = (JSpinner.NumberEditor) editor; numberEditor.getFormat().applyPattern(format); preferredSize = calculateDimensionForFormat(format); } else if (editor instanceof JSpinner.DateEditor) { JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor; ... |
JSpinner | generateSpinnerFor(Object... objs) generate Spinner For Container c = search(objs, Container.class); String[] name_value = search(objs, String[].class); ChangeListener listener = search(objs, ChangeListener.class); SpinnerModel model = search(objs, SpinnerModel.class); Color color = search(objs, Color.class); Dimension dimension = search(objs, Dimension.class); Font font = search(objs, Font.class); Rectangle bounds = search(objs, Rectangle.class); ... |