gui.buttons
Class MinMaxSpinnerModel

java.lang.Object
  extended by javax.swing.AbstractSpinnerModel
      extended by javax.swing.SpinnerNumberModel
          extended by gui.buttons.MinMaxSpinnerModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.SpinnerModel

public class MinMaxSpinnerModel
extends javax.swing.SpinnerNumberModel

Spinner model that allows the user to specify minimum and maximum input values, for example to define a range for an Axis}.

This spinnermodel is designed to be used with a pair of spinners.

One spinner lets the user specify the maximum value of a range and the other spinner lets him specify the minimum value. Both spinners are limited within the range provided in the constructor arguments min and max.

However, in order to function correctly, each spinner also needs a reference to its counterpart in order to make sure that the min value spinner does not allow the user to choose a value that is larger than the one set in the max value spinner and vice versa. Through this setting, the spinner also understands whether it is a lower bound or an upper bound spinner, because it is only provided with a reference to the opposite spinner.

See Also:
Serialized Form

Constructor Summary
MinMaxSpinnerModel(int min, int max)
          Instantiates a new min max spinner model.
 
Method Summary
 void setLowerBoundSpinner(javax.swing.JSpinner lowerBoundSpinner)
          Sets the lower bound spinner.
 void setUpperBoundSpinner(javax.swing.JSpinner upperBoundSpinner)
          Sets the upper bound spinner.
 void setValue(java.lang.Object value)
           
 
Methods inherited from class javax.swing.SpinnerNumberModel
getMaximum, getMinimum, getNextValue, getNumber, getPreviousValue, getStepSize, getValue, setMaximum, setMinimum, setStepSize
 
Methods inherited from class javax.swing.AbstractSpinnerModel
addChangeListener, getChangeListeners, getListeners, removeChangeListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MinMaxSpinnerModel

public MinMaxSpinnerModel(int min,
                          int max)
Instantiates a new min max spinner model.

Parameters:
min - the min
max - the max
Method Detail

setValue

public void setValue(java.lang.Object value)
Specified by:
setValue in interface javax.swing.SpinnerModel
Overrides:
setValue in class javax.swing.SpinnerNumberModel

setLowerBoundSpinner

public void setLowerBoundSpinner(javax.swing.JSpinner lowerBoundSpinner)
Sets the lower bound spinner. Only used for upper bound spinners.

Parameters:
lowerBoundSpinner - the new lower bound spinner

setUpperBoundSpinner

public void setUpperBoundSpinner(javax.swing.JSpinner upperBoundSpinner)
Sets the upper bound spinner. Only used for lower bound spinners.

Parameters:
upperBoundSpinner - the new upper bound spinner