Class SpinnerField

All Implemented Interfaces:
ActionListener, FocusListener, ImageObserver, MenuContainer, Serializable, EventListener

public class SpinnerField extends JComponent implements ActionListener, FocusListener
A wrapper around a component implementing the CyclerListener interface and a Cycler component. Clicking on the up/down arrow buttons of the Cycler component results in notifications being sent to the CyclerListener component.
Version:
%revision%
See Also:
  • Field Details

  • Constructor Details

    • SpinnerField

      public SpinnerField()
      Creates a new SpinnerField instance containing an IntegerTextField
    • SpinnerField

      public SpinnerField(ValidatedTextField l, boolean newVersion)
      Creates a new SpinnerField containing the given ValidatedTextField This version of the SpinnerField uses JButton's with arrow glyphs instead of the Cycler component for the up/down arrows. It also uses a BoxLayout instead of a GridBag (if that makes any difference).
      Parameters:
      field - - the ValidatedTextField to use
    • SpinnerField

      public SpinnerField(ValidatedTextField l)
      Creates a new SpinnerField containing the given ValidatedTextField
      Parameters:
      field - - the ValidatedTextField to use
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent ae)
      Specified by:
      actionPerformed in interface ActionListener
    • requestFocus

      public void requestFocus()
      Override requestFocus to pass it on to the actual text field
      Overrides:
      requestFocus in class JComponent
    • setLayout

      public void setLayout(LayoutManager lm)
      Overrides:
      setLayout in class Container
    • setBackground

      public void setBackground(Color bg)
      Overrides:
      setBackground in class JComponent
    • setValue

      public void setValue(Object val)
    • getValue

      public Object getValue()
      Used to retrieve the value of component as an Object (Double, Integer) instead of a String (using getText()).
      Returns:
      the numeric value of the component
    • addChangeListener

      public void addChangeListener(ChangeListener l)
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
    • setMaximumValue

      public void setMaximumValue(int max)
      Sets the maximum value allowed when spinning up Currently only supported for IntegerTextField components
      Parameters:
      max - the max value
    • getMaximumValue

      public int getMaximumValue()
      Gets the maximum value allowed when spinning up Currently only supported for IntegerTextField components
      Returns:
      the maximum value
    • setMinimumValue

      public void setMinimumValue(int min)
      Sets the minimum value allowed when spinning up Currently only supported for IntegerTextField components
      Parameters:
      min - the minimum value
    • getMinimumValue

      public int getMinimumValue()
      Gets the minimum value allowed when spinning up Currently only supported for IntegerTextField components
      Returns:
      the minimum value
    • setEnabled

      public void setEnabled(boolean b)
      Enables/disables the subcomponents that comprise the main component
      Overrides:
      setEnabled in class JComponent
      Parameters:
      b - If true, the component is enabled; otherwise it is disabled.
    • focusGained

      public void focusGained(FocusEvent e)
      Invoked when a component gains the keyboard focus.
      Specified by:
      focusGained in interface FocusListener
      Parameters:
      event - The focus event
    • focusLost

      public void focusLost(FocusEvent e)
      Invoked when a component loses the keyboard focus.
      Specified by:
      focusLost in interface FocusListener
      Parameters:
      event - The focus event