com.tensegrity.gui.swing.control.spinbutton
Class IntegerSpinButton

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.tensegrity.gui.swing.control.spinbutton.AbstractSpinButton
                      extended bycom.tensegrity.gui.swing.control.spinbutton.IntegerSpinButton
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.LayoutManager, java.awt.MenuContainer, java.io.Serializable

public class IntegerSpinButton
extends com.tensegrity.gui.swing.control.spinbutton.AbstractSpinButton

The IntegerSpinButton implements the SpinButton control for Integer values.

Version:
$Id: IntegerSpinButton.java,v 1.2 2004/09/21 09:59:47 GillesIachelini Exp $
Author:
GillesIachelini
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
IntegerSpinButton(java.lang.Number min, java.lang.Number max, java.lang.Number step, java.lang.Number initial)
          Creates a new IntegerSpinButton based on the given values.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Sets the internal value according the pressed button and posts the event to all listeners of action events.
protected  java.lang.Number add(java.lang.Number left, java.lang.Number right)
          Invoked by this class whenever its required to add a certain value to another.
 void addActionListener(java.awt.event.ActionListener listener)
          Method addActionListener adds the given listener to the internal list of ActionListeners.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          does nothing.
 void decreaseValue()
          Decreases the number by the step that can be defined using AbstractSpinButton.setStep(Number).
 java.lang.Number getMaximum()
          Returns the upper bound of this SpinButton.
 java.lang.Number getMinimum()
          Returns the minimum of this SpinButton.
 java.lang.Number getStep()
          Returns the current step value.
 java.lang.Number getValue()
          Returns the value.
 void increaseValue()
          Increases the number by the step that can be defined using AbstractSpinButton.setStep(Number).
 void layoutContainer(java.awt.Container parent)
          Layouts the two buttons vertical where the up button is on top and the down button below.
protected  java.lang.Number max(java.lang.Number left, java.lang.Number right)
          Invoked by this class whenever its required to determine the maximum of two values of type Number.
protected  java.lang.Number min(java.lang.Number left, java.lang.Number right)
          Invoked by this class whenever its required to determine the minimum of two values of type Number.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Returns the preferredLayoutSize of the parent.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferredSize of this SpinButton by combining the preferred sizes of the two contained buttons.
 void removeLayoutComponent(java.awt.Component comp)
          does nothing.
 void removeListener(java.awt.event.ActionListener listener)
          Method removeListener removes the given listener from the internal list of ActionListeners.
 void setEnabled(boolean enabled)
           
 void setMaximum(java.lang.Number maximum)
          Changes the upper bound for numbers to the given one.
 void setMinimum(java.lang.Number minimum)
          Changes the lower bound for numbers to the given one.
 void setStep(java.lang.Number step)
          Sets the new step value.
 void setValue(java.lang.Number value)
          Sets the value.
protected  java.lang.Number substract(java.lang.Number left, java.lang.Number right)
          Invoked by this class whenever its required to subtract a certain value from another.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, 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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setFont, 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, hasFocus, 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
 

Constructor Detail

IntegerSpinButton

public IntegerSpinButton(java.lang.Number min,
                         java.lang.Number max,
                         java.lang.Number step,
                         java.lang.Number initial)
Creates a new IntegerSpinButton based on the given values.

Parameters:
min - the minimum.
max - the maximum.
step - the step value.
initial - the initial value.
Method Detail

substract

protected java.lang.Number substract(java.lang.Number left,
                                     java.lang.Number right)
Description copied from class: com.tensegrity.gui.swing.control.spinbutton.AbstractSpinButton
Invoked by this class whenever its required to subtract a certain value from another. Since Java doesn't allow operator overloading, we have to implement the minus-operand by this method.

Parameters:
left - the first summand.
right - the second summand.
Returns:
the result of the subtraction of eft-right as an instance of Number.

add

protected java.lang.Number add(java.lang.Number left,
                               java.lang.Number right)
Description copied from class: com.tensegrity.gui.swing.control.spinbutton.AbstractSpinButton
Invoked by this class whenever its required to add a certain value to another. Since Java doesn't allow operator overloading, we have to implement the plus-operand by this method.

Parameters:
left - the first summand.
right - the second summand.
Returns:
the result of the addition of left+right as an instance of Number.

max

protected java.lang.Number max(java.lang.Number left,
                               java.lang.Number right)
Description copied from class: com.tensegrity.gui.swing.control.spinbutton.AbstractSpinButton
Invoked by this class whenever its required to determine the maximum of two values of type Number. This method should behave similar to the Math.max(int, int) (or double, float, etc.) method.

Parameters:
left - the first value.
right - the second value.
Returns:
the result of the max(left,right) as an instance of Number.

min

protected java.lang.Number min(java.lang.Number left,
                               java.lang.Number right)
Description copied from class: com.tensegrity.gui.swing.control.spinbutton.AbstractSpinButton
Invoked by this class whenever its required to determine the minimum of two values of type Number. This method should behave similar to the Math.min(int, int) (or double, float, etc.) method.

Parameters:
left - the first value.
right - the second value.
Returns:
the result of the min(left,right) as an instance of Number.

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Method addActionListener adds the given listener to the internal list of ActionListeners.

Parameters:
listener - the listener of ActionEvents.

removeListener

public void removeListener(java.awt.event.ActionListener listener)
Method removeListener removes the given listener from the internal list of ActionListeners.

Parameters:
listener - the listener to remove.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Sets the internal value according the pressed button and posts the event to all listeners of action events.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
ActionListener.actionPerformed(ActionEvent)

increaseValue

public final void increaseValue()
Increases the number by the step that can be defined using AbstractSpinButton.setStep(Number). Internally method AbstractSpinButton.add(Number, Number) is called, which must be defined by a subclass.


decreaseValue

public final void decreaseValue()
Decreases the number by the step that can be defined using AbstractSpinButton.setStep(Number). Internally method AbstractSpinButton.add(Number, Number) is called, which must be defined by a subclass.


addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
does nothing.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
See Also:
LayoutManager.addLayoutComponent(String, Component)

layoutContainer

public void layoutContainer(java.awt.Container parent)
Layouts the two buttons vertical where the up button is on top and the down button below.

Specified by:
layoutContainer in interface java.awt.LayoutManager
See Also:
LayoutManager.layoutContainer(Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Returns the preferredLayoutSize of the parent.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
See Also:
LayoutManager.minimumLayoutSize(Container)

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferredSize of this SpinButton by combining the preferred sizes of the two contained buttons.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
See Also:
LayoutManager.preferredLayoutSize(Container)

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
does nothing.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
See Also:
LayoutManager.removeLayoutComponent(Component)

getValue

public java.lang.Number getValue()
Returns the value.

Returns:
int the current value as int.

setValue

public void setValue(java.lang.Number value)
Sets the value.

Parameters:
value - The value to set

setMinimum

public void setMinimum(java.lang.Number minimum)
Changes the lower bound for numbers to the given one.

Parameters:
minimum - the new lower bound.

getMinimum

public java.lang.Number getMinimum()
Returns the minimum of this SpinButton.

Returns:
the minimum of this SpinButton as an instance of Number.

setMaximum

public void setMaximum(java.lang.Number maximum)
Changes the upper bound for numbers to the given one.

Parameters:
maximum - the new upper bound

getMaximum

public java.lang.Number getMaximum()
Returns the upper bound of this SpinButton.

Returns:
the upper bound as an instance of class Number.

setEnabled

public void setEnabled(boolean enabled)
See Also:
JComponent.setEnabled(boolean)

getStep

public java.lang.Number getStep()
Returns the current step value.

Returns:
the step value as float.

setStep

public void setStep(java.lang.Number step)
Sets the new step value.

Parameters:
step - The new step to set.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.