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

Field Summary
private  javax.swing.JSpinner lowerBoundSpinner
          Reference to the lower bound spinner.
private  int max
          The maximum value.
private  int min
          The minimum value.
(package private) static long serialVersionUID
          The version tracking unique identifier for Serialization.
private  javax.swing.JSpinner upperBoundSpinner
          Reference to the upper bound spinner.
 
Fields inherited from class javax.swing.AbstractSpinnerModel
listenerList
 
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, fireStateChanged, getChangeListeners, getListeners, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
The version tracking unique identifier for Serialization.

See Also:
Constant Field Values

min

private int min
The minimum value.


max

private int max
The maximum value.


upperBoundSpinner

private javax.swing.JSpinner upperBoundSpinner
Reference to the upper bound spinner. Only used by the lower bound spinner


lowerBoundSpinner

private javax.swing.JSpinner lowerBoundSpinner
Reference to the lower bound spinner. Only used by the upper bound spinner

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