org.ssonet.awt
Class Spinner

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.ssonet.awt.Spinner
All Implemented Interfaces:
java.awt.Adjustable, java.awt.event.AdjustmentListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class Spinner
extends javax.swing.JComponent
implements java.awt.Adjustable, java.awt.event.AdjustmentListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.MouseListener

A typein field for an integer.

See Also:
Serialized Form

Field Summary
protected  int ascent
           
protected  java.awt.Color backgroundColor
           
protected  boolean borderPainted
           
protected  java.awt.Dimension d
           
protected  int digitsTyped
           
protected  java.awt.FontMetrics fm
           
protected  boolean haveFocus
           
protected  int leadingPad
           
protected  int maxValue
           
protected  int minValue
           
protected  int nDigits
           
protected  java.lang.String txt
           
protected  int value
           
 boolean wrapped
           
protected  boolean wraps
           
 
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.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.Adjustable
HORIZONTAL, NO_ORIENTATION, VERTICAL
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Spinner(int startValue)
           
Spinner(int startValue, java.lang.String t)
           
 
Method Summary
 void addAdjustmentListener(java.awt.event.AdjustmentListener l)
          Add a listener to recieve adjustment events when the value of the Spinner changes.
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
          Spinners can both send and recieve AdjustmentEvents -- they can be cascaded together for situations where there are multiple ways to enter the same value (popup menu or typin number)
protected  void fireAdjustmentValueChanged(java.awt.event.AdjustmentEvent e)
          Notify all listeners that have registered interest for notification on this event type.
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 java.awt.Color getBackgroundColor()
           
 int getBlockIncrement()
          Does nothing -- part of the Adjustable interface.
 int getDigits()
           
 int getLeadingPad()
           
 int getMaximum()
          Gets the maximum value of the Spinner.
 int getMinimum()
          Gets the minimum value of the Spinner.
 int getOrientation()
          Does nothing -- part of the Adjustable interface.
 java.lang.String getText()
           
 org.ssonet.awt.SpinnerUI getUI()
           
 java.lang.String getUIClassID()
           
 int getUnitIncrement()
          Does nothing -- part of the Adjustable interface.
 int getValue()
          Gets the current value of the Spinner object.
 int getVisibleAmount()
          Does nothing -- part of the Adjustable interface.
 boolean getWrap()
           
 boolean hasFocus()
           
 boolean isBorderPainted()
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void paintBorder(java.awt.Graphics g)
          Paint the spinner's border if BorderPainted property is true.
 void removeAdjustmentListener(java.awt.event.AdjustmentListener l)
          Removes an adjustment listener.
 void setBackgroundColor(java.awt.Color newColor)
           
 void setBlockIncrement(int b)
          Does nothing -- part of the Adjustable interface.
 void setBorderPainted(boolean b)
           
 void setDigits(int n)
           
 void setFont(java.awt.Font f)
           
 void setLeadingPad(int newPad)
           
 void setMaximum(int max)
          Sets the maximum value of the Spinner.
 void setMinimum(int min)
          Sets the minimum value of the Spinner.
 void setText(java.lang.String s)
          A Spinner can have a string associated with it, which is placed at the right of the number
 void setUI(org.ssonet.awt.SpinnerUI ui)
           
 void setUnitIncrement(int u)
          Does nothing -- part of the Adjustable interface.
 void setValue(int v)
          Sets the current value of the Spinner.
 void setVisibleAmount(int v)
          Does nothing -- part of the Adjustable interface.
 void setWrap(boolean w)
          A Spinner for which wrapping is true wraps around to the minimum value when the maximum value is exceeded, and vice versa.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

txt

protected java.lang.String txt

d

protected java.awt.Dimension d

ascent

protected int ascent

value

protected int value

haveFocus

protected boolean haveFocus

minValue

protected int minValue

maxValue

protected int maxValue

fm

protected java.awt.FontMetrics fm

nDigits

protected int nDigits

digitsTyped

protected int digitsTyped

wraps

protected boolean wraps

borderPainted

protected boolean borderPainted

backgroundColor

protected java.awt.Color backgroundColor

leadingPad

protected int leadingPad

wrapped

public boolean wrapped
Constructor Detail

Spinner

public Spinner(int startValue,
               java.lang.String t)

Spinner

public Spinner(int startValue)
Method Detail

getValue

public int getValue()
Gets the current value of the Spinner object.

Specified by:
getValue in interface java.awt.Adjustable

setValue

public void setValue(int v)
Sets the current value of the Spinner. This value must be within the range defined by the minimum and maximum values for this object.

Specified by:
setValue in interface java.awt.Adjustable
Parameters:
v - the current value

setWrap

public void setWrap(boolean w)
A Spinner for which wrapping is true wraps around to the minimum value when the maximum value is exceeded, and vice versa.

Parameters:
w - true if wrapping is to be enabled, false if the value is to be clamped.

getWrap

public boolean getWrap()

setText

public void setText(java.lang.String s)
A Spinner can have a string associated with it, which is placed at the right of the number

Parameters:
s - the new text value

getText

public java.lang.String getText()

setFont

public void setFont(java.awt.Font f)
Overrides:
setFont in class javax.swing.JComponent

setDigits

public void setDigits(int n)

getDigits

public int getDigits()

setLeadingPad

public void setLeadingPad(int newPad)

getLeadingPad

public int getLeadingPad()

setBackgroundColor

public void setBackgroundColor(java.awt.Color newColor)

getBackgroundColor

public java.awt.Color getBackgroundColor()

hasFocus

public boolean hasFocus()
Overrides:
hasFocus in class java.awt.Component

isBorderPainted

public boolean isBorderPainted()

setBorderPainted

public void setBorderPainted(boolean b)

paintBorder

protected void paintBorder(java.awt.Graphics g)
Paint the spinner's border if BorderPainted property is true.

Overrides:
paintBorder in class javax.swing.JComponent
See Also:
JComponent.paint(java.awt.Graphics), JComponent.setBorder(javax.swing.border.Border)

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
Spinners can both send and recieve AdjustmentEvents -- they can be cascaded together for situations where there are multiple ways to enter the same value (popup menu or typin number)

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener

setMinimum

public void setMinimum(int min)
Sets the minimum value of the Spinner.

Specified by:
setMinimum in interface java.awt.Adjustable
Parameters:
min - the minimum value

getMinimum

public int getMinimum()
Gets the minimum value of the Spinner.

Specified by:
getMinimum in interface java.awt.Adjustable

setMaximum

public void setMaximum(int max)
Sets the maximum value of the Spinner.

Specified by:
setMaximum in interface java.awt.Adjustable
Parameters:
max - the maximum value

getMaximum

public int getMaximum()
Gets the maximum value of the Spinner.

Specified by:
getMaximum in interface java.awt.Adjustable

addAdjustmentListener

public void addAdjustmentListener(java.awt.event.AdjustmentListener l)
Add a listener to recieve adjustment events when the value of the Spinner changes.

Specified by:
addAdjustmentListener in interface java.awt.Adjustable
Parameters:
l - the listener to recieve events
See Also:
AdjustmentEvent

removeAdjustmentListener

public void removeAdjustmentListener(java.awt.event.AdjustmentListener l)
Removes an adjustment listener.

Specified by:
removeAdjustmentListener in interface java.awt.Adjustable
Parameters:
l - the listener being removed
See Also:
AdjustmentEvent

fireAdjustmentValueChanged

protected void fireAdjustmentValueChanged(java.awt.event.AdjustmentEvent e)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


setUnitIncrement

public void setUnitIncrement(int u)
Does nothing -- part of the Adjustable interface.

Specified by:
setUnitIncrement in interface java.awt.Adjustable
Parameters:
u - the unit increment

getUnitIncrement

public int getUnitIncrement()
Does nothing -- part of the Adjustable interface.

Specified by:
getUnitIncrement in interface java.awt.Adjustable

setBlockIncrement

public void setBlockIncrement(int b)
Does nothing -- part of the Adjustable interface.

Specified by:
setBlockIncrement in interface java.awt.Adjustable
Parameters:
b - the block increment

getBlockIncrement

public int getBlockIncrement()
Does nothing -- part of the Adjustable interface.

Specified by:
getBlockIncrement in interface java.awt.Adjustable

setVisibleAmount

public void setVisibleAmount(int v)
Does nothing -- part of the Adjustable interface.

Specified by:
setVisibleAmount in interface java.awt.Adjustable
Parameters:
v - the length of the indicator

getVisibleAmount

public int getVisibleAmount()
Does nothing -- part of the Adjustable interface.

Specified by:
getVisibleAmount in interface java.awt.Adjustable

getOrientation

public int getOrientation()
Does nothing -- part of the Adjustable interface.

Specified by:
getOrientation in interface java.awt.Adjustable

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

getUI

public org.ssonet.awt.SpinnerUI getUI()

setUI

public void setUI(org.ssonet.awt.SpinnerUI ui)

updateUI

public void updateUI()
Overrides:
updateUI in class javax.swing.JComponent

getUIClassID

public java.lang.String getUIClassID()
Overrides:
getUIClassID in class javax.swing.JComponent
Returns:
"SpinnerUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)


Copyright © 2003 DRIM Team. All Rights Reserved.