List of usage examples for javax.swing JSpinner addChangeListener
public void addChangeListener(ChangeListener listener)
From source file:org.rockyroadshub.planner.core.gui.calendar.FormPane.java
private void setAllowsInvalid(JSpinner s) { JFormattedTextField txt = ((JSpinner.NumberEditor) s.getEditor()).getTextField(); ((NumberFormatter) txt.getFormatter()).setAllowsInvalid(false); s.addChangeListener((ChangeEvent e) -> { if (s.getValue().equals(24)) { s.setValue(0);//from w w w.j av a2 s.c o m } }); }
From source file:org.rockyroadshub.planner.core.gui.calendar.FormPane.java
private void setAllowsInvalid(JSpinner s1, JSpinner s2) { JFormattedTextField txt = ((JSpinner.NumberEditor) s1.getEditor()).getTextField(); ((NumberFormatter) txt.getFormatter()).setAllowsInvalid(false); s1.addChangeListener((ChangeEvent e) -> { if (s1.getValue().equals(60)) { s1.setValue(0);/*ww w . j a va2s. c o m*/ int i = (int) s2.getValue() + 1; s2.setValue(i); } }); }
From source file:org.squidy.designer.zoom.impl.VisualizationShape.java
/** * /*from w ww . j a v a 2 s . c o m*/ */ private final void initTimeSpinner() { PBounds bounds = getBoundsReference(); final JSpinner spinner = new JSpinner(new SpinnerNumberModel(sampleTime, 1000, 10000, 500)); spinner.addChangeListener(new ChangeListener() { /* * (non-Javadoc) * * @see * javax.swing.event.ChangeListener#stateChanged(javax.swing.event * .ChangeEvent) */ public void stateChanged(ChangeEvent e) { sampleTime = ((Double) spinner.getValue()).longValue(); invalidatePaint(); } }); timeSpinner = new JComponentWrapper(spinner); timeSpinner.setOffset((bounds.getWidth() * 0.25) - (timeSpinner.getWidth() / 2), bounds.getHeight() * 0.75 + 0.25); addChild(timeSpinner); }
From source file:richtercloud.reflection.form.builder.typehandler.NumberTypeHandler.java
@Override public Pair<JComponent, ComponentHandler<?>> handle(Type type, Number fieldValue, String fieldName, Class<?> declaringClass, final FieldUpdateListener<FieldUpdateEvent<Number>> updateListener, ReflectionFormBuilder reflectionFormBuilder) throws IllegalArgumentException, IllegalAccessException, FieldHandlingException { //@TODO: handle validaton annotations (should cover all cases, so no // need to develop own annotations JSpinner retValue = new JSpinner(new SpinnerNumberModel(fieldValue, null, null, 1)); retValue.addChangeListener(new ChangeListener() { @Override//from www .jav a2 s . c om public void stateChanged(ChangeEvent e) { updateListener.onUpdate(new FieldUpdateEvent<>((Number) ((JSpinner) e.getSource()).getValue())); } }); return new ImmutablePair<JComponent, ComponentHandler<?>>(retValue, this); }