org.formaria.swing
Class Spinner

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JSpinner
                  extended by org.formaria.swing.Spinner
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, ErrorDisplay, ListenerHelper, TextHolder, ValueHolder

public class Spinner
extends javax.swing.JSpinner
implements javax.swing.event.ChangeListener, ListenerHelper, ValueHolder, ErrorDisplay

An Up-Down control or spin edit component

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from formaria.

$Revision: 1.14 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JSpinner
javax.swing.JSpinner.AccessibleJSpinner, javax.swing.JSpinner.DateEditor, javax.swing.JSpinner.DefaultEditor, javax.swing.JSpinner.ListEditor, javax.swing.JSpinner.NumberEditor
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String errorMessage
           
protected  int errorStatus
           
static int SPINNER_TYPE_DOUBLE
           
static int SPINNER_TYPE_INT
           
protected  javax.swing.SpinnerNumberModel spinnerModel
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Spinner()
          Create a new spinner
 
Method Summary
 void addHandler(java.lang.Object page, java.lang.String type, java.lang.String methodName)
          Add a new event handler
 void addNotify()
          Repaint the component once it has been created
 int getIntValue()
          Get the object's value
 double getMax()
          Gets the value corresponding to the maximum value of the meter
 double getMin()
          Gets the value corresponding to the minimum value of the meter
 double getStep()
          Gets the step size for the spinner
 java.lang.String getText()
          Get the text/label of the component
 java.lang.Object getValue()
          Get the object's value
 void init()
          Performs any post creation initialisation of the control.
 void paint(java.awt.Graphics g)
           
 void setBackground(java.awt.Color c)
          Set the background color of the editor component
 void setBuddy(Edit je)
          Set an edit component to update
 void setDataType(java.lang.String type)
           
 void setErrorMessage(java.lang.String errorMsg)
          Set the error message
 void setErrorStatus(int status)
          Set the error status
 void setForeground(java.awt.Color c)
          Set the foreground color of the editor component
 void setMax(double _value)
          Sets the value corresponding to the maximum value of the meter
 void setMin(double _value)
          Sets the value corresponding to the minimum value of the meter
 void setRange(int min, int max)
          Set the spinner range
 void setStep(double _value)
          Sets the step size for the spinner
 void setText(java.lang.String s)
          Get the text/label of the component
 void setValue(java.lang.Object value)
          Set the value associated with this component
 void stateChanged(javax.swing.event.ChangeEvent e)
          The state changed
 
Methods inherited from class javax.swing.JSpinner
addChangeListener, commitEdit, createEditor, fireStateChanged, getAccessibleContext, getChangeListeners, getEditor, getModel, getNextValue, getPreviousValue, getUI, getUIClassID, removeChangeListener, setEditor, setModel, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

spinnerModel

protected javax.swing.SpinnerNumberModel spinnerModel

SPINNER_TYPE_INT

public static final int SPINNER_TYPE_INT
See Also:
Constant Field Values

SPINNER_TYPE_DOUBLE

public static final int SPINNER_TYPE_DOUBLE
See Also:
Constant Field Values

errorStatus

protected int errorStatus

errorMessage

protected java.lang.String errorMessage
Constructor Detail

Spinner

public Spinner()
Create a new spinner

Method Detail

setForeground

public void setForeground(java.awt.Color c)
Set the foreground color of the editor component

Overrides:
setForeground in class javax.swing.JComponent
Parameters:
c - the new color

setBackground

public void setBackground(java.awt.Color c)
Set the background color of the editor component

Overrides:
setBackground in class javax.swing.JComponent
Parameters:
c - the new color

setBuddy

public void setBuddy(Edit je)
Set an edit component to update

Parameters:
je - the component to update

setRange

public void setRange(int min,
                     int max)
Set the spinner range

Parameters:
min - the max value
max - the minimum value

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
The state changed

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
e - the state event

init

public void init()
          throws java.io.IOException
Performs any post creation initialisation of the control.

Throws:
java.io.IOException - This component diesnt do any IO, but the exception is a boilerplate

setMax

public void setMax(double _value)
Sets the value corresponding to the maximum value of the meter

Parameters:
_value - the new max value

setMin

public void setMin(double _value)
Sets the value corresponding to the minimum value of the meter

Parameters:
_value - the new min value

setStep

public void setStep(double _value)
Sets the step size for the spinner

Parameters:
_value - the new step size

setDataType

public void setDataType(java.lang.String type)

getMax

public double getMax()
Gets the value corresponding to the maximum value of the meter

Returns:
the max value

getMin

public double getMin()
Gets the value corresponding to the minimum value of the meter

Returns:
the min value

getStep

public double getStep()
Gets the step size for the spinner

Returns:
the step size

addNotify

public void addNotify()
Repaint the component once it has been created

Overrides:
addNotify in class javax.swing.JComponent

addHandler

public void addHandler(java.lang.Object page,
                       java.lang.String type,
                       java.lang.String methodName)
                throws java.lang.NoSuchMethodException
Add a new event handler

Specified by:
addHandler in interface ListenerHelper
Parameters:
page - the owner page
type - the event handler type
methodName - the method name
Throws:
java.lang.NoSuchMethodException - through if the method cannot be found

getValue

public java.lang.Object getValue()
Get the object's value

Specified by:
getValue in interface ValueHolder
Overrides:
getValue in class javax.swing.JSpinner
Returns:
the value for this object

getIntValue

public int getIntValue()
Get the object's value

Returns:
the value for this object

setValue

public void setValue(java.lang.Object value)
Set the value associated with this component

Specified by:
setValue in interface ValueHolder
Overrides:
setValue in class javax.swing.JSpinner
Parameters:
newValue - the new object value

setText

public void setText(java.lang.String s)
Get the text/label of the component

Specified by:
setText in interface TextHolder
Parameters:
s - the new text

getText

public java.lang.String getText()
Get the text/label of the component

Specified by:
getText in interface TextHolder
Returns:
the component's text

setErrorStatus

public void setErrorStatus(int status)
Set the error status

Specified by:
setErrorStatus in interface ErrorDisplay
Parameters:
status -

setErrorMessage

public void setErrorMessage(java.lang.String errorMsg)
Set the error message

Specified by:
setErrorMessage in interface ErrorDisplay
Parameters:
errorMsg - the message text

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent