JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class AbstractSpinBox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.util.swing.AbstractSpinBox
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JCSpinBox, JCSpinField, JCSpinNumberBox

public abstract class AbstractSpinBox
extends JComponent

Abstract base for creating spinboxes.

See Also:
Serialized Form

Nested Class Summary
 class AbstractSpinBox.ArrowButton
          Arrow button used to match look and feel.
 class AbstractSpinBox.MetalArrowButton
          Arrow button for Metal look and feel.
static class AbstractSpinBox.MetalBorder
          Generates a border for the Metal look and feel.
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean arrowKeySpinningAllowed
           
protected  Timer buttonTimer
           
protected  boolean continuousScroll
           
protected  JButton currentButton
           
protected static int DECREMENT
           
protected  JButton downArrow
           
protected  boolean editable
           
protected  com.klg.jclass.util.swing.JCSpinBoxEditor editor
           
protected static boolean editorIsValidateRoot
           
protected static int INCREMENT
           
protected  com.klg.jclass.util.swing.AbstractSpinBox.Listener l
           
protected static Border metalBorder
           
protected static int minimumHeight
           
protected static int NONE
           
protected  com.klg.jclass.util.swing.JCSpinBoxRenderer renderer
           
protected  JPanel renderPanel
           
protected  com.klg.jclass.util.swing.AbstractSpinBox.RendererListener rl
           
protected  JButton upArrow
           
protected  Font userFont
           
protected  com.klg.jclass.util.JCListenerList valueListeners
           
protected  com.klg.jclass.util.value.JCValueModel valueModel
           
 
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
AbstractSpinBox()
          Creates an empty Spin Control.
AbstractSpinBox(com.klg.jclass.util.value.JCValueModel model, com.klg.jclass.util.swing.JCSpinBoxEditor editor)
          Creates an empty Spin Control.
AbstractSpinBox(com.klg.jclass.util.value.JCValueModel model, com.klg.jclass.util.swing.JCSpinBoxEditor editor, com.klg.jclass.util.swing.JCSpinBoxRenderer renderer)
          Constructor for the abstract protion of the spinbox.
 
Method Summary
 void addValueListener(com.klg.jclass.util.value.JCValueListener listener)
          Adds a listener to listen for changes to the value.
protected abstract  void checkArrowButtons()
          Abstract method that check if arrows should be enabled or disabled.
 boolean compareToValue(Object compare_value)
          Compares any object to the stored value.
 void configureArrowButtons()
          Creates and sets up the spin arrows.
protected  JButton createDecrArrow()
          Creates the decrement arrow.
protected  JButton createIncrArrow()
          Creates the increment arrow.
protected  void doBorder()
           
protected  void doFocusedLook(Graphics g)
           
 void doLayout()
          Positions the text field and arrow buttons.
protected  void doNonFocusedLook(Graphics g)
           
 JButton getDecrementArrow()
          Gets the decrement (down) button.
 com.klg.jclass.util.swing.JCSpinBoxEditor getEditor()
          Get the editor being used by this spinbox.
 JButton getIncrementArrow()
          Gets the increment (up) button.
 Dimension getPreferredSize()
          Returns the preferred size of the Spin Field.
 com.klg.jclass.util.swing.JCSpinBoxRenderer getRenderer()
          Get the renderer being used by this spinbox
 com.klg.jclass.util.value.JCValueModel getValueModel()
          Get the value model.
protected  void handleKeyPressed(KeyEvent e)
          Overridden in JCSpinBox to add keySelectionManager functionality
 boolean isArrowKeySpinningAllowed()
          Returns whether or not the up/down arrow keys can be used for spinning.
 boolean isContinuousScroll()
          Return the continuousScroll property.
 boolean isEditable()
          Returns true if the JCSpinBox is editable.
 boolean isEnabled()
          Test to see if the component is enabled.
 boolean isFocusTraversable()
          Test to see if this component is focus traversable
 void paint(Graphics g)
          Paint the spinbox.
protected  int preferredHeightOfView()
          Returns the text field's preferred height.
protected  int preferredWidthOfView()
          Returns the sum of the text field's and arrow button's preferred widths.
protected  void processFocusLost(FocusEvent e)
           
protected  void processValueChanged(com.klg.jclass.util.value.JCValueEvent ev)
          This method can be overridded by the subclass
protected  void processValueChanging(com.klg.jclass.util.value.JCValueEvent ev)
          This method can be overridded by the subclass
 void removeValueListener(com.klg.jclass.util.value.JCValueListener listener)
          Removes a listener that listens for changes to the value.
 void requestFocus()
          Request the focus for this component.
 void setArrowEnabled(JButton arrow, boolean enabled)
          For use by concrete implementations of the checkArrowButtons to safely disable the buttons as necessary.
 void setArrowKeySpinningAllowed(boolean value)
          Sets whether or not the up/down arrow keys can be used for spinning.
 void setBackground(Color background)
          Sets background of the Spin field
 void setContinuousScroll(boolean continuousScroll)
          Should arrow buttons continuously scroll when the the mouse button is held down, or discretely (jump) scroll on each mouse click?
 void setEditable(boolean aFlag)
          Determines whether the JCSpinBox field is editable.
 void setEditor(com.klg.jclass.util.swing.JCSpinBoxEditor editor)
          Sets the editor used to paint and edit the selected item in the JCSpinBox field.
 void setEnabled(boolean b)
          Set the enable state of this component.
 void setFont(Font f)
          Sets the font for this component.
 void setForeground(Color foreground)
          Sets foreground color of the Spin field
 void setLayout(LayoutManager mgr)
          Sets the layout manager for this container.
 void setLocale(Locale l)
          Sets the locale of this component.
 void setRenderer(com.klg.jclass.util.swing.JCSpinBoxRenderer aRenderer)
          Set the renderer for this spinbox to use.
 void setUI(ComponentUI ui)
          Set UI.
 void setValue(Object o)
          Set the value displayed by the spin box.
 void setValueModel(com.klg.jclass.util.value.JCValueModel model)
          Set the value model.
protected abstract  Object spinDown()
          Return the new value generated when spinning down a notch
protected abstract  Object spinUp()
          Return the new value generated when spinning up a notch
protected  void swapEditorRenderer()
           
 void updateUI()
          Update UI.
 
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, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, 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, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, 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, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, 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, 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

continuousScroll

protected boolean continuousScroll

editor

protected com.klg.jclass.util.swing.JCSpinBoxEditor editor

renderer

protected com.klg.jclass.util.swing.JCSpinBoxRenderer renderer

userFont

protected Font userFont

renderPanel

protected JPanel renderPanel

downArrow

protected JButton downArrow

upArrow

protected JButton upArrow

arrowKeySpinningAllowed

protected boolean arrowKeySpinningAllowed

l

protected com.klg.jclass.util.swing.AbstractSpinBox.Listener l

rl

protected com.klg.jclass.util.swing.AbstractSpinBox.RendererListener rl

buttonTimer

protected Timer buttonTimer

currentButton

protected JButton currentButton

valueModel

protected com.klg.jclass.util.value.JCValueModel valueModel

valueListeners

protected com.klg.jclass.util.JCListenerList valueListeners

editable

protected boolean editable

minimumHeight

protected static int minimumHeight

editorIsValidateRoot

protected static boolean editorIsValidateRoot

metalBorder

protected static final Border metalBorder

NONE

protected static final int NONE
See Also:
Constant Field Values

INCREMENT

protected static final int INCREMENT
See Also:
Constant Field Values

DECREMENT

protected static final int DECREMENT
See Also:
Constant Field Values
Constructor Detail

AbstractSpinBox

public AbstractSpinBox(com.klg.jclass.util.value.JCValueModel model,
                       com.klg.jclass.util.swing.JCSpinBoxEditor editor,
                       com.klg.jclass.util.swing.JCSpinBoxRenderer renderer)
Constructor for the abstract protion of the spinbox.


AbstractSpinBox

public AbstractSpinBox(com.klg.jclass.util.value.JCValueModel model,
                       com.klg.jclass.util.swing.JCSpinBoxEditor editor)
Creates an empty Spin Control.


AbstractSpinBox

public AbstractSpinBox()
Creates an empty Spin Control.

Method Detail

setContinuousScroll

public void setContinuousScroll(boolean continuousScroll)
Should arrow buttons continuously scroll when the the mouse button is held down, or discretely (jump) scroll on each mouse click?

Parameters:
continuousScroll - a boolean, true means scroll continuously while the mouse is held down, false (the default) means scroll one value per mouse click.

isContinuousScroll

public boolean isContinuousScroll()
Return the continuousScroll property.

Returns:
true if continuous scrolling is in effect, false otherwise.

setUI

public void setUI(ComponentUI ui)
Set UI.

Overrides:
setUI in class JComponent

updateUI

public void updateUI()
Update UI.

Overrides:
updateUI in class JComponent

addValueListener

public void addValueListener(com.klg.jclass.util.value.JCValueListener listener)
Adds a listener to listen for changes to the value.


removeValueListener

public void removeValueListener(com.klg.jclass.util.value.JCValueListener listener)
Removes a listener that listens for changes to the value.


setValueModel

public void setValueModel(com.klg.jclass.util.value.JCValueModel model)
Set the value model.


getValueModel

public com.klg.jclass.util.value.JCValueModel getValueModel()
Get the value model.


setValue

public void setValue(Object o)
Set the value displayed by the spin box.

Parameters:
o - The new value

compareToValue

public boolean compareToValue(Object compare_value)
Compares any object to the stored value.


createIncrArrow

protected JButton createIncrArrow()
Creates the increment arrow.


createDecrArrow

protected JButton createDecrArrow()
Creates the decrement arrow.


configureArrowButtons

public void configureArrowButtons()
Creates and sets up the spin arrows.


requestFocus

public void requestFocus()
Request the focus for this component.

Overrides:
requestFocus in class JComponent

setEditable

public void setEditable(boolean aFlag)
Determines whether the JCSpinBox field is editable. An editable JCSpinBox allows the user to type into the field or selected an item from the list to initialize the field, after which it can be edited. (The editing affects only the field, the list item remains intact.) A non editable JCSpinBox displays the selected item inthe field, but the selection cannot be modified.

Parameters:
aFlag - A boolean value, where true indicates that the field is editable

isEditable

public boolean isEditable()
Returns true if the JCSpinBox is editable.

Returns:
true if the JCSpinBox is editable, else false

setEnabled

public void setEnabled(boolean b)
Set the enable state of this component.

Overrides:
setEnabled in class JComponent

isEnabled

public boolean isEnabled()
Test to see if the component is enabled.

Overrides:
isEnabled in class Component

isFocusTraversable

public boolean isFocusTraversable()
Test to see if this component is focus traversable

Overrides:
isFocusTraversable in class Component

setEditor

public void setEditor(com.klg.jclass.util.swing.JCSpinBoxEditor editor)
Sets the editor used to paint and edit the selected item in the JCSpinBox field. The editor is used only if the receiving JCSpinBox is editable. If not editable, the combo box uses the renderer to paint the selected item.

Parameters:
editor - that displays the selected item
See Also:
setRenderer(com.klg.jclass.util.swing.JCSpinBoxRenderer)

getEditor

public com.klg.jclass.util.swing.JCSpinBoxEditor getEditor()
Get the editor being used by this spinbox.


setRenderer

public void setRenderer(com.klg.jclass.util.swing.JCSpinBoxRenderer aRenderer)
Set the renderer for this spinbox to use.


getRenderer

public com.klg.jclass.util.swing.JCSpinBoxRenderer getRenderer()
Get the renderer being used by this spinbox


swapEditorRenderer

protected void swapEditorRenderer()

getDecrementArrow

public JButton getDecrementArrow()
Gets the decrement (down) button.


getIncrementArrow

public JButton getIncrementArrow()
Gets the increment (up) button.


isArrowKeySpinningAllowed

public boolean isArrowKeySpinningAllowed()
Returns whether or not the up/down arrow keys can be used for spinning.

See Also:
setArrowKeySpinningAllowed(boolean)

setArrowKeySpinningAllowed

public void setArrowKeySpinningAllowed(boolean value)
Sets whether or not the up/down arrow keys can be used for spinning. This is true by default, and useful to turn off if you wish to use the arrow keys for traversal.


preferredWidthOfView

protected int preferredWidthOfView()
Returns the sum of the text field's and arrow button's preferred widths. Commonly overridden by implementing class depeding on its data metrics.


getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of the Spin Field.

Overrides:
getPreferredSize in class JComponent

preferredHeightOfView

protected int preferredHeightOfView()
Returns the text field's preferred height. Designed to be overridden


setBackground

public void setBackground(Color background)
Sets background of the Spin field

Overrides:
setBackground in class JComponent

setForeground

public void setForeground(Color foreground)
Sets foreground color of the Spin field

Overrides:
setForeground in class JComponent

setFont

public void setFont(Font f)
Sets the font for this component. Overrides JComponent's setFont to make sure that the font is passed on to the editor/renderer and to make sure the preferred size gets recalculated.

Overrides:
setFont in class JComponent
Parameters:
f - The desired Font for this component
See Also:
JComponent.setFont(java.awt.Font)

setLocale

public void setLocale(Locale l)
Sets the locale of this component. Overrides the setLocale of java.awt.Component to make sure the preferred sized gets recalculated.

Overrides:
setLocale in class Component
Parameters:
l - the locale to become this component's locale
See Also:
Component.setLocale(java.util.Locale)

doLayout

public void doLayout()
Positions the text field and arrow buttons.

Overrides:
doLayout in class Container

doFocusedLook

protected void doFocusedLook(Graphics g)

doNonFocusedLook

protected void doNonFocusedLook(Graphics g)

doBorder

protected void doBorder()

paint

public void paint(Graphics g)
Paint the spinbox.

Overrides:
paint in class JComponent

setArrowEnabled

public void setArrowEnabled(JButton arrow,
                            boolean enabled)
For use by concrete implementations of the checkArrowButtons to safely disable the buttons as necessary.


checkArrowButtons

protected abstract void checkArrowButtons()
Abstract method that check if arrows should be enabled or disabled. Use setArrowEnabled to enable/disable the arrow buttons. This will do so in a thread and state friendly manner.

See Also:
setArrowEnabled(javax.swing.JButton, boolean)

spinUp

protected abstract Object spinUp()
Return the new value generated when spinning up a notch


spinDown

protected abstract Object spinDown()
Return the new value generated when spinning down a notch


processValueChanging

protected void processValueChanging(com.klg.jclass.util.value.JCValueEvent ev)
This method can be overridded by the subclass


processValueChanged

protected void processValueChanged(com.klg.jclass.util.value.JCValueEvent ev)
This method can be overridded by the subclass


handleKeyPressed

protected void handleKeyPressed(KeyEvent e)
Overridden in JCSpinBox to add keySelectionManager functionality


setLayout

public final void setLayout(LayoutManager mgr)
Sets the layout manager for this container. This method is overridden to prevent the layout manager from being set.

Overrides:
setLayout in class Container

processFocusLost

protected void processFocusLost(FocusEvent e)

Copyright © 2004 Quest Software Inc..
All rights reserved.