com.ibm.spinner
Class SpinnerGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.ibm.spinner.SpinnerGUI
Direct Known Subclasses:
Spinner

public class SpinnerGUI
extends javax.swing.JPanel
implements javax.swing.SwingConstants, java.awt.event.KeyListener, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.MouseListener

SpinnerGUI defines the common features that the spinner GUI has: two buttorns for increasing and decreasing the value, one text field for displaying and editing the value.


Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int SPIN_HORIZONTAL
          Horizontal arrangement of spinner's direction buttons.
static int SPIN_VERTICAL
          Vertical arrangement of spinner's direction buttons.
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
 
Constructor Summary
SpinnerGUI()
          Constructs and initializes the spinner's GUI.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Event method of ActionListener.
 void focusGained(java.awt.event.FocusEvent e)
          Event method of FocusListener.
 void focusLost(java.awt.event.FocusEvent e)
          Event method of FocusListener.
 int getColumns()
          Gets the columns of the text field which is used to display the current selected item.
 java.awt.Color getDecrButtonArrowColor()
          Gets the arrow color in the decrment button.
 java.awt.Color getIncrButtonArrowColor()
          Gets the arrow color of the incrment button.
 java.awt.Dimension getMaximumSize()
          Gets the maximum size of the spinner.
 java.awt.Dimension getMinimumSize()
          Gets the minimum size of the spinner.
 int getOrientation()
          Returns the spinner's orientation which represents the arrangement of the two spin buttons(horizontal or vertical).
 java.awt.Dimension getPreferredSize()
          Gets the preferred size of this spinner.
 boolean isEditable()
          Gets the editable property of spinner.
 boolean isEnabled()
          Gets the enabled property of spinner.
 void keyPressed(java.awt.event.KeyEvent e)
          Event method of KeyListener.
 void keyReleased(java.awt.event.KeyEvent e)
          Event method of KeyListener.
 void keyTyped(java.awt.event.KeyEvent e)
          Event method of KeyListener.
 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)
           
 void setBackground(java.awt.Color newColor)
          Sets background color of the text field.
 void setColumns(int newColumns)
          Sets the columns of the text field which is used to display the current selected item.
 void setDecrButtonArrowColor(java.awt.Color newColor)
          Sets the arrow color in the decrment button.
 void setEditable(boolean b)
          Sets whether the spinner can be edited or not.
 void setEnabled(boolean b)
          Sets whether the spinner can be used or not.
 void setFont(java.awt.Font newFont)
          Sets text font of the text field.
 void setForeground(java.awt.Color newColor)
          Sets foreground color of the text field.
 void setIncrButtonArrowColor(java.awt.Color newColor)
          Sets the arrow color of the incrment button.
 void setOpaque(boolean b)
          Sets whether the spinner can be opaque or not.
 void setOrientation(int newOrientation)
          Sets the spinner's orientation to either SPIN_VERTICAL or SPIN_HORIZONTAL.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPIN_VERTICAL

public static final int SPIN_VERTICAL
Vertical arrangement of spinner's direction buttons.

SPIN_HORIZONTAL

public static final int SPIN_HORIZONTAL
Horizontal arrangement of spinner's direction buttons.
Constructor Detail

SpinnerGUI

public SpinnerGUI()
Constructs and initializes the spinner's GUI.
Method Detail

setOrientation

public void setOrientation(int newOrientation)
Sets the spinner's orientation to either SPIN_VERTICAL or SPIN_HORIZONTAL.
Parameters:
newOrientation - new arrangement of two scroll buttons
Throws:
java.lang.IllegalArgumentException - if orientation is not one of SPIN_VERTICAL, SPIN_HORIZONTAL

getOrientation

public int getOrientation()
Returns the spinner's orientation which represents the arrangement of the two spin buttons(horizontal or vertical).
Returns:
SPIN_VERTICAL or SPIN_HORIZONTAL

setColumns

public void setColumns(int newColumns)
Sets the columns of the text field which is used to display the current selected item. This method doesn't work for ObjectListSpinner since this kind of spinner does not necessarilly use a text field to display the selected item.
Parameters:
newColumns - the columns to be set,it should be more than 0

getColumns

public int getColumns()
Gets the columns of the text field which is used to display the current selected item. This method doesn't work for ObjectListSpinner since this kind of spinner does not necessarilly use a text field to display the selected item.
Returns:
an int that represents the current columns of the textfield.

setIncrButtonArrowColor

public void setIncrButtonArrowColor(java.awt.Color newColor)
Sets the arrow color of the incrment button.
Parameters:
newColor - new color of the incrment arrow

getIncrButtonArrowColor

public java.awt.Color getIncrButtonArrowColor()
Gets the arrow color of the incrment button.
Returns:
the color of the incrment arrow

setDecrButtonArrowColor

public void setDecrButtonArrowColor(java.awt.Color newColor)
Sets the arrow color in the decrment button.
Parameters:
newColor - the color of the decrment arrow

getDecrButtonArrowColor

public java.awt.Color getDecrButtonArrowColor()
Gets the arrow color in the decrment button.
Returns:
the color of the decrment arrow

setEnabled

public void setEnabled(boolean b)
Sets whether the spinner can be used or not.
Parameters:
b - true or false, true represents the spinner can be used.
Overrides:
setEnabled in class javax.swing.JComponent

isEnabled

public boolean isEnabled()
Gets the enabled property of spinner.
Returns:
If true, the spinner can be used.
Overrides:
isEnabled in class java.awt.Component

setEditable

public void setEditable(boolean b)
Sets whether the spinner can be edited or not.
Parameters:
b - true or false. If true the spinner can be edited.

isEditable

public boolean isEditable()
Gets the editable property of spinner.
Returns:
If true, the spinner can be edited.

setOpaque

public void setOpaque(boolean b)
Sets whether the spinner can be opaque or not.
Parameters:
b - true or false. If true the spinner background will be filled with the background color.
Overrides:
setOpaque in class javax.swing.JComponent

setFont

public void setFont(java.awt.Font newFont)
Sets text font of the text field.
Parameters:
newFont - the text font
Overrides:
setFont in class javax.swing.JComponent

setForeground

public void setForeground(java.awt.Color newColor)
Sets foreground color of the text field.
Parameters:
newColor - the text field foreground color
Overrides:
setForeground in class javax.swing.JComponent

setBackground

public void setBackground(java.awt.Color newColor)
Sets background color of the text field.
Parameters:
newColor - the text field background color
Overrides:
setBackground in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred size of this spinner.
Overrides:
getPreferredSize in class javax.swing.JComponent

getMinimumSize

public java.awt.Dimension getMinimumSize()
Gets the minimum size of the spinner.
Overrides:
getMinimumSize in class javax.swing.JComponent

getMaximumSize

public java.awt.Dimension getMaximumSize()
Gets the maximum size of the spinner.
Overrides:
getMaximumSize in class javax.swing.JComponent

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Event method of ActionListener.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

keyTyped

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

keyReleased

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

keyPressed

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

focusGained

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

focusLost

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

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