dog.gui
Class DSpinbox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--dog.gui.DContainer
                    |
                    +--dog.gui.DTextComponent
                          |
                          +--dog.gui.DSpinbox
All Implemented Interfaces:
java.awt.Adjustable, java.awt.datatransfer.ClipboardOwner, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable, TimerListener

public class DSpinbox
extends DTextComponent
implements java.awt.Adjustable, TimerListener

A component that allows the editing of an integer.

You may specify an alignment (LEFT, CENTER, or RIGHT) for the text within the component.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.event.ActionListener actionListener
           
protected  java.awt.event.AdjustmentListener adjustmentListener
           
protected  int align
          The alignment of the value in the spinbox.
static int CENTER
          The center alignment.
protected  int down
          Which button is currently being pressed?
protected static int DOWN
           
protected  boolean filled
          Is this component filled?
protected  boolean focus
          Do we currently have the focus?
static int LEFT
          The left alignment.
protected  int maximum
          The maximum value of the spinbox.
protected  int minimum
          The minimum value of the spinbox.
protected static int NONE
           
static int RIGHT
          The right alignment.
protected  int unitIncrement
          The amount by which the spinbox increments or decrements its value.
protected static int UP
           
protected  int value
          The value in the spinbox.
 
Fields inherited from class dog.gui.DTextComponent
editable, position, selectionEnd, selectionStart, text, textListener
 
Fields inherited from class dog.gui.DContainer
cancelButton, defaultButton, EAST, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, tooltip, WEST
 
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, VERTICAL
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DSpinbox()
          Constructs a new spinbox.
DSpinbox(int value)
          Constructs a new spinbox initialized with the specified value.
DSpinbox(int value, int align)
          Constructs a new spinbox with the specified value and alignment.
DSpinbox(int value, int minimum, int maximum)
          Constructs a new spinbox with the specified value, minimum, and maximum.
DSpinbox(int value, int minimum, int maximum, int align)
          Constructs a new spinbox with the specified value, minimum, maximum, and alignment.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this component.
 void addAdjustmentListener(java.awt.event.AdjustmentListener listener)
          Adds the specified adjustment listener to receive adjustment events from this component.
 int getAlign()
          Returns the alignment of the text in this spinbox.
 int getBlockIncrement()
          Returns the amount by which the value increases or decreases when the spinbox buttons are pressed.
 int getMaximum()
          Returns the maximum value of this spinbox.
 int getMinimum()
          Returns the minimum value of this spinbox.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size for this component.
 int getOrientation()
          Don't know why this applies to Adjustables.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size for this component.
 int getUnitIncrement()
          Returns the amount by which the value increases or decreases when the spinbox buttons are pressed.
 int getValue()
          Returns the current value of this spinbox.
 int getVisibleAmount()
          Don't know why this applies to Adjustables.
 boolean isFilled()
          Indicates whether this component is filled.
 boolean isFocusTraversable()
          This component is focus-traversable if it is not disabled.
 void paint(java.awt.Graphics g)
          Paints this choice.
protected  java.lang.String paramString()
          Returns a parameter string for this component.
protected  void processActionEvent(java.awt.event.ActionEvent event)
          Processes action events occurring on this component by dispatching them to any registered ActionListener objects.
protected  void processAdjustmentEvent(java.awt.event.AdjustmentEvent event)
          Processes adjustment events on this component by dispatching them to any registered AdjustmentListener objects.
protected  void processEvent(java.awt.AWTEvent event)
          Processes events on this component.
protected  void processFocusEvent(java.awt.event.FocusEvent event)
          Process focus events.
protected  void processKeyEvent(java.awt.event.KeyEvent event)
          Process key events.
protected  void processMouseEvent(java.awt.event.MouseEvent event)
          Process mouse events.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent event)
          Process mouse motion events.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified action listener so that it no longer receives action events from this component.
 void removeAdjustmentListener(java.awt.event.AdjustmentListener listener)
          Removes the specified adjustment listener so that it no longer receives adjustment events from this component.
 void setAlign(int align)
          Sets the alignment of the text in this spinbox.
 void setBlockIncrement(int blockIncrement)
          Sets the amount by which the value increases or decreases when the spinbox buttons are pressed.
 void setFilled(boolean filled)
          Sets whether to fill this component with the fill colour.
 void setMaximum(int maximum)
          Sets the maximum value for this spinbox.
 void setMinimum(int minimum)
          Sets the minimum value for this spinbox.
 void setOrientation(int orientation)
          Don't know why this applies to Adjustables.
 void setUnitIncrement(int unitIncrement)
          Sets the amount by which the value increases or decreases when the spinbox buttons are pressed.
 void setValue(int value)
          Sets the value of this spinbox to the specified value.
 void setValues(int value, int minimum, int maximum)
          Sets the values for this spinbox.
 void setVisibleAmount(int amount)
          Don't know why this applies to Adjustables.
 void timerFired(TimerEvent event)
          The timer fired, blink the caret.
 void update(java.awt.Graphics g)
          Updates this component's graphics context.
 
Methods inherited from class dog.gui.DTextComponent
addTextListener, copySelection, cutSelection, deleteLeft, deleteRight, deleteSelection, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, insert, insert, isEditable, lostOwnership, moveLeft, moveLineEnd, moveLineStart, moveRight, moveWordLeft, moveWordRight, pasteSelection, processTextEvent, removeTextListener, select, selectAll, setEditable, setSelectionEnd, setSelectionStart, setText
 
Methods inherited from class dog.gui.DContainer
addImpl, addPropertyChangeListener, alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, getCancelButton, getComponent, getDefaultButton, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getTooltip, isPreloadImages, processCancelAction, processDefaultAction, removePropertyChangeListener, setCancelButton, setDefaultButton, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
The center alignment.

LEFT

public static final int LEFT
The left alignment.

RIGHT

public static final int RIGHT
The right alignment.

value

protected int value
The value in the spinbox.

maximum

protected int maximum
The maximum value of the spinbox.

minimum

protected int minimum
The minimum value of the spinbox.

unitIncrement

protected int unitIncrement
The amount by which the spinbox increments or decrements its value.

align

protected int align
The alignment of the value in the spinbox.

filled

protected boolean filled
Is this component filled?

focus

protected transient boolean focus
Do we currently have the focus?

down

protected transient int down
Which button is currently being pressed?

NONE

protected static final int NONE

UP

protected static final int UP

DOWN

protected static final int DOWN

actionListener

protected transient java.awt.event.ActionListener actionListener

adjustmentListener

protected transient java.awt.event.AdjustmentListener adjustmentListener
Constructor Detail

DSpinbox

public DSpinbox()
Constructs a new spinbox.

DSpinbox

public DSpinbox(int value)
Constructs a new spinbox initialized with the specified value.
Parameters:
value - the value to be displayed

DSpinbox

public DSpinbox(int value,
                int align)
Constructs a new spinbox with the specified value and alignment.
Parameters:
value - the value to be displayed
align - LEFT, CENTER, or RIGHT

DSpinbox

public DSpinbox(int value,
                int minimum,
                int maximum)
Constructs a new spinbox with the specified value, minimum, and maximum.
Parameters:
value - the value to be displayed
minimum - the minimum value
maximum - the maximum value

DSpinbox

public DSpinbox(int value,
                int minimum,
                int maximum,
                int align)
Constructs a new spinbox with the specified value, minimum, maximum, and alignment.
Parameters:
value - the value to be displayed
minimum - the minimum value
maximum - the maximum value
align - LEFT, CENTER, or RIGHT
Method Detail

getValue

public int getValue()
Returns the current value of this spinbox.
Specified by:
getValue in interface java.awt.Adjustable
See Also:
getMinimum(), getMaximum()

setValue

public void setValue(int value)
Sets the value of this spinbox to the specified value.
Specified by:
setValue in interface java.awt.Adjustable
Parameters:
value - the new value of the spinbox. If this value is below the current minimum or above the current maximum minus the visible amount, it becomes the new one of those values, respectively.
See Also:
getValue()

getMinimum

public int getMinimum()
Returns the minimum value of this spinbox.
Specified by:
getMinimum in interface java.awt.Adjustable
See Also:
getMaximum(), getValue()

setMinimum

public void setMinimum(int minimum)
Sets the minimum value for this spinbox.
Specified by:
setMinimum in interface java.awt.Adjustable
Parameters:
minimum - the minimum value of the spinbox

getMaximum

public int getMaximum()
Returns the maximum value of this spinbox.
Specified by:
getMaximum in interface java.awt.Adjustable
See Also:
getMinimum(), getValue()

setMaximum

public void setMaximum(int maximum)
Sets the maximum value for this spinbox.
Specified by:
setMaximum in interface java.awt.Adjustable
Parameters:
maximum - the maximum value of the spinbox

setValues

public void setValues(int value,
                      int minimum,
                      int maximum)
Sets the values for this spinbox. This method enforces the following constraints: Values which do not meet these criteria are quietly coerced to the appropriate boundary value.
Parameters:
value - is the position in the current window.
minimum - is the minimum value of the scrollbar
maximum - is the maximum value of the scrollbar

getUnitIncrement

public int getUnitIncrement()
Returns the amount by which the value increases or decreases when the spinbox buttons are pressed.
Specified by:
getUnitIncrement in interface java.awt.Adjustable

setUnitIncrement

public void setUnitIncrement(int unitIncrement)
Sets the amount by which the value increases or decreases when the spinbox buttons are pressed.
Specified by:
setUnitIncrement in interface java.awt.Adjustable

getBlockIncrement

public int getBlockIncrement()
Returns the amount by which the value increases or decreases when the spinbox buttons are pressed.
Specified by:
getBlockIncrement in interface java.awt.Adjustable

setBlockIncrement

public void setBlockIncrement(int blockIncrement)
Sets the amount by which the value increases or decreases when the spinbox buttons are pressed.
Specified by:
setBlockIncrement in interface java.awt.Adjustable

getAlign

public int getAlign()
Returns the alignment of the text in this spinbox.
See Also:
setAlign(int)

setAlign

public void setAlign(int align)
Sets the alignment of the text in this spinbox.
Parameters:
align - LEFT, CENTER, or RIGHT
Throws:
java.lang.IllegalArgumentException - if the alignment is not one of the above.
See Also:
getAlign()

isFilled

public boolean isFilled()
Indicates whether this component is filled.

setFilled

public void setFilled(boolean filled)
Sets whether to fill this component with the fill colour.

getOrientation

public int getOrientation()
Don't know why this applies to Adjustables. Returns 0.
Specified by:
getOrientation in interface java.awt.Adjustable

getVisibleAmount

public int getVisibleAmount()
Don't know why this applies to Adjustables. Returns 0.
Specified by:
getVisibleAmount in interface java.awt.Adjustable

setOrientation

public void setOrientation(int orientation)
Don't know why this applies to Adjustables. Does nothing.

setVisibleAmount

public void setVisibleAmount(int amount)
Don't know why this applies to Adjustables. Does nothing.
Specified by:
setVisibleAmount in interface java.awt.Adjustable

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size for this component.
Overrides:
getMinimumSize in class java.awt.Container

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size for this component.
Overrides:
getPreferredSize in class java.awt.Container

update

public void update(java.awt.Graphics g)
Updates this component's graphics context.
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paints this choice.
Overrides:
paint in class java.awt.Container

isFocusTraversable

public boolean isFocusTraversable()
This component is focus-traversable if it is not disabled.
Overrides:
isFocusTraversable in class java.awt.Component

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this component.
Parameters:
listener - the action listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener so that it no longer receives action events from this component.
Parameters:
listener - the action listener

addAdjustmentListener

public void addAdjustmentListener(java.awt.event.AdjustmentListener listener)
Adds the specified adjustment listener to receive adjustment events from this component.
Specified by:
addAdjustmentListener in interface java.awt.Adjustable
Parameters:
listener - the adjustment listener

removeAdjustmentListener

public void removeAdjustmentListener(java.awt.event.AdjustmentListener listener)
Removes the specified adjustment listener so that it no longer receives adjustment events from this component.
Specified by:
removeAdjustmentListener in interface java.awt.Adjustable
Parameters:
listener - the adjustment listener

processEvent

protected void processEvent(java.awt.AWTEvent event)
Processes events on this component. If the event is an ActionEvent, it invokes the processActionEvent method, else it invokes its superclass's processEvent.
Overrides:
processEvent in class DTextComponent
Parameters:
event - the event

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)
Processes action events occurring on this component by dispatching them to any registered ActionListener objects.
Parameters:
event - the action event

processAdjustmentEvent

protected void processAdjustmentEvent(java.awt.event.AdjustmentEvent event)
Processes adjustment events on this component by dispatching them to any registered AdjustmentListener objects.
Parameters:
event - the adjustment event

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent event)
Process focus events.
Overrides:
processFocusEvent in class java.awt.Component

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent event)
Process key events.
Overrides:
processKeyEvent in class java.awt.Component

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent event)
Process mouse events.
Overrides:
processMouseEvent in class DContainer

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent event)
Process mouse motion events.
Overrides:
processMouseMotionEvent in class DContainer

timerFired

public void timerFired(TimerEvent event)
The timer fired, blink the caret. Check for repeats.
Specified by:
timerFired in interface TimerListener

paramString

protected java.lang.String paramString()
Returns a parameter string for this component.
Overrides:
paramString in class DTextComponent