com.ibm.spinner
Class NumericSpinner

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.ibm.spinner.SpinnerGUI
                                |
                                +--com.ibm.spinner.Spinner
                                      |
                                      +--com.ibm.spinner.NumericSpinner

public class NumericSpinner
extends Spinner
implements javax.swing.event.ChangeListener

A spinner which scrolls through a list of integers with bounded range. The current selected value is displayed in a textfield. The user can also enters an integer value as the current value.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Fields inherited from class com.ibm.spinner.SpinnerGUI
SPIN_HORIZONTAL, SPIN_VERTICAL
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
NumericSpinner()
          Creates a NumericSpinner using a bounded range model with a minimum as 0, maximum as 100, increment as 1 and current value as 0.
NumericSpinner(int increment)
          Creates a NumericSpinner using a bounded range model with a minimum as 0, maximum as 100 and current value as 0.
NumericSpinner(int min, int max)
          Creates a NumericSpinner using a bounded range model with specified minimum and maximum value.
NumericSpinner(int value, int min, int max, int increment)
          Creates a NumericSpinner using a bounded range model with specified values.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
 void focusLost(java.awt.event.FocusEvent e)
          Invoked when a component loses the keyboard focus
 java.lang.String getAboutThisBean()
          Returns a special formatted string intended for use by the editor of this property.
 java.awt.Color getBackground()
          Gets the background color
 java.awt.Font getFont()
          Returns the font
 java.awt.Color getForeground()
          Returns the textfield foreground color
 int getIncrement()
          Returns the increment value of NumericSpinner.
 int getMaximum()
          Returns the maximum value of NumericSpinner.
 int getMinimum()
          Returns the minimum value of NumericSpinner.
 javax.swing.BoundedRangeModel getModel()
          Returns the data model currently used by the NumericSpinner.
 int getValue()
          Returns the current value of NumericSpinner.
 void initMaximum(int maximum)
          Sets the maximum value of NumericSpinner.
 void initMinimum(int minimum)
          Sets the maximum value of NumericSpinner.
 boolean isEditable()
          Indicates whether or not this text component is editable.
 boolean isEnabled()
          Determines whether this component is enabled.
 boolean isSpinnable()
          Indicates whether or not this text component is spinnable.
 void keyPressed(java.awt.event.KeyEvent e)
          Event method of KeyListener.
 void keyTyped(java.awt.event.KeyEvent e)
          Event method of KeyListener.
 void scrollDown()
          Decrements the spinner's value by the increment.
 void scrollUp()
          Increments the spinner's value by the increment.
 void setAboutThisBean(java.lang.String aboutThisBean)
          Setter method for the aboutThisBean property to be available in the properties list.
 void setBackground(java.awt.Color c)
          Sets the background color of this component.
 void setEditable(boolean aBoolean)
          Sets whether text editing is enabled.
 void setEnabled(boolean b)
          Enables or disables this component, depending on the value of the parameter b.
 void setFont(java.awt.Font f)
          Sets the font of this component.
 void setForeground(java.awt.Color c)
          Sets the foreground color of this component.
 void setIncrement(int increment)
          Sets the increment value of NumericSpinner.
 void setMaximum(int maximum)
          Sets the maximum value of NumericSpinner.
 void setMinimum(int minimum)
          Sets the minimum value of NumericSpinner.
 void setModel(javax.swing.BoundedRangeModel newModel)
          Sets the data model that the NumericSpinner uses to spin through.
 void setSpinnable(boolean aBoolean)
          Sets whether text spinning is enabled.
 void setValue(int value)
          Sets the current value of NumericSpinner.
 
Methods inherited from class com.ibm.spinner.Spinner
addChangeListener, addSpinnerErrorEventListener, isWrap, removeChangeListener, removeSpinnerErrorEventListener, setWrap
 
Methods inherited from class com.ibm.spinner.SpinnerGUI
focusGained, getColumns, getDecrButtonArrowColor, getEditable, getIncrButtonArrowColor, getMaximumSize, getMinimumSize, getOrientation, getPreferredSize, keyReleased, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, setColumns, setDecrButtonArrowColor, setIncrButtonArrowColor, setOpaque, setOrientation, setToolTipText, stateChanged
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumericSpinner

public NumericSpinner()
Creates a NumericSpinner using a bounded range model with a minimum as 0, maximum as 100, increment as 1 and current value as 0.

NumericSpinner

public NumericSpinner(int increment)
Creates a NumericSpinner using a bounded range model with a minimum as 0, maximum as 100 and current value as 0.
Parameters:
increment - the amount of the current value changes when scrolling up or down.

NumericSpinner

public NumericSpinner(int min,
                      int max)
Creates a NumericSpinner using a bounded range model with specified minimum and maximum value. The current value is set to the min value and the increment is set to 1.
Parameters:
min - the minimum value of the bounded range model.
max - the maximum value of the bounded range model.

NumericSpinner

public NumericSpinner(int value,
                      int min,
                      int max,
                      int increment)
Creates a NumericSpinner using a bounded range model with specified values.
Parameters:
value - the current value being displayed.
min - the minimum value of the bounded range model.
max - the maximum value of the bounded range model.
increment - the amount of the current value changes when scrolling up or down.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Invoked when a component loses the keyboard focus
Parameters:
e - FocusEvent
Overrides:
focusLost in class SpinnerGUI

getAboutThisBean

public java.lang.String getAboutThisBean()
Returns a special formatted string intended for use by the editor of this property.
Returns:
the special formatted string for use by the editor of this property

getBackground

public java.awt.Color getBackground()
Gets the background color
Returns:
java.awt.Color
Overrides:
getBackground in class java.awt.Component

getFont

public java.awt.Font getFont()
Returns the font
Returns:
java.awt.Font
Overrides:
getFont in class java.awt.Component

getForeground

public java.awt.Color getForeground()
Returns the textfield foreground color
Returns:
java.awt.Color
Overrides:
getForeground in class java.awt.Component

getIncrement

public int getIncrement()
Returns the increment value of NumericSpinner.
Returns:
the increment value.

getMaximum

public int getMaximum()
Returns the maximum value of NumericSpinner.
Returns:
the maximum value.

getMinimum

public int getMinimum()
Returns the minimum value of NumericSpinner.
Returns:
the minimum value.

getModel

public javax.swing.BoundedRangeModel getModel()
Returns the data model currently used by the NumericSpinner.
Returns:
the BoundedRangeModel that provides numeric values to spin through.

getValue

public int getValue()
Returns the current value of NumericSpinner.
Returns:
the current value.

initMaximum

public void initMaximum(int maximum)
Sets the maximum value of NumericSpinner.
Parameters:
the - maximum value to set.

initMinimum

public void initMinimum(int minimum)
Sets the maximum value of NumericSpinner.
Parameters:
the - maximum value to set.

isEditable

public boolean isEditable()
Indicates whether or not this text component is editable.
Returns:
true if this text component is editable; false otherwise.
Overrides:
isEditable in class SpinnerGUI
Since:
JDK1ble
See Also:
setEditable(boolean)

isEnabled

public boolean isEnabled()
Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default. A component may be enabled or disabled by calling its setEnabled method.
Returns:
true if the component is enabled; false otherwise.
Overrides:
isEnabled in class SpinnerGUI
Since:
JDK1.0
See Also:
setEnabled(boolean)

isSpinnable

public boolean isSpinnable()
Indicates whether or not this text component is spinnable.
Returns:
true if this text component is spinnable; false otherwise.
Overrides:
isSpinnable in class SpinnerGUI
Since:
JDK1ble
See Also:
setSpinnable(boolean)

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Event method of KeyListener.
Parameters:
e - KeyEvent
Overrides:
keyPressed in class Spinner

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Event method of KeyListener.
Parameters:
e - KeyEvent
Overrides:
keyTyped in class SpinnerGUI

scrollDown

public void scrollDown()
Decrements the spinner's value by the increment.
Overrides:
scrollDown in class SpinnerGUI

scrollUp

public void scrollUp()
Increments the spinner's value by the increment.
Overrides:
scrollUp in class SpinnerGUI

setAboutThisBean

public void setAboutThisBean(java.lang.String aboutThisBean)
Setter method for the aboutThisBean property to be available in the properties list. This method should not be used to set the aboutThisBean preperty value.
Parameters:
newValue - the special formatted string

setBackground

public void setBackground(java.awt.Color c)
Sets the background color of this component.
Parameters:
c - The color to become this component's background color.
Overrides:
setBackground in class SpinnerGUI
Since:
JDK1.0
See Also:
getBackground()

setEditable

public void setEditable(boolean aBoolean)
Sets whether text editing is enabled.
Parameters:
aBoolean - boolean
Overrides:
setEditable in class SpinnerGUI

setEnabled

public void setEnabled(boolean b)
Enables or disables this component, depending on the value of the parameter b. An enabled component can respond to user input and generate events. Components are enabled initially by default.
Parameters:
b - If true, this component is enabled; otherwise this component is disabled.
Overrides:
setEnabled in class SpinnerGUI
Since:
JDK1.1
See Also:
isEnabled()

setFont

public void setFont(java.awt.Font f)
Sets the font of this component.
Parameters:
f - The font to become this component's font.
Overrides:
setFont in class SpinnerGUI
Since:
JDK1.0
See Also:
getFont()

setForeground

public void setForeground(java.awt.Color c)
Sets the foreground color of this component.
Parameters:
c - The color to become this component's foreground color.
Overrides:
setForeground in class SpinnerGUI
Since:
JDK1.0
See Also:
getForeground()

setIncrement

public void setIncrement(int increment)
Sets the increment value of NumericSpinner.
Parameters:
increment - the increment value to set.
Throws:
java.lang.IllegalArgumentException - if the increment is not greater than 0

setMaximum

public void setMaximum(int maximum)
Sets the maximum value of NumericSpinner.
Parameters:
the - maximum value to set.

setMinimum

public void setMinimum(int minimum)
Sets the minimum value of NumericSpinner.
Parameters:
minimum - the minimum value to set.

setModel

public void setModel(javax.swing.BoundedRangeModel newModel)
Sets the data model that the NumericSpinner uses to spin through.
Parameters:
newModel - the BoundedRangeModel that provides numeric values to spin through.

setSpinnable

public void setSpinnable(boolean aBoolean)
Sets whether text spinning is enabled.
Parameters:
aBoolean - boolean
Overrides:
setSpinnable in class SpinnerGUI

setValue

public void setValue(int value)
Sets the current value of NumericSpinner.
Parameters:
the - value to be set.
Throws:
java.lang.IllegalArgumentException - when the value is entered from actionPerformed or focusLost, if the value is greater than the maximum and less than the minimum.