synapsi.gui.util
Class SpinControl


java.lang.Object

  |

  +--java.awt.Component

        |

        +--java.awt.Container

              |

              +--javax.swing.JComponent

                    |

                    +--javax.swing.JPanel

                          |

                          +--synapsi.gui.util.SpinControl

Direct Known Subclasses:
NumberSpinControl

public abstract class SpinControl
extends javax.swing.JPanel
implements java.awt.event.ActionListener, java.awt.event.FocusListener

Abstract base class for different spin controls. Extending class must provide implementation for functions protected void increase() and protected void decrease() to handle correct updating of spin control values. User should also provide functions for returning spin controls value that convert getValueInner's returnvalue to correct datatype. If direct editing of spin controls value is enabled, user should also provide public function that uses setValueInner.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
 
Constructor Summary
SpinControl(javax.swing.text.Document document, java.lang.String initString)
          Constructs new SpinControl, assingns a document and initial String for it
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handles increase and decrease-buttons by calling increase() or decrease() Fires also event notifying all listeners of change in SpinControls value.
 void addActionListener(java.awt.event.ActionListener listener)
          Adds action listener to spin controls textField
protected abstract  void decrease()
          Decrease the value of SpinControl
 void editAllowed(boolean enabled)
          Enables or disables direct editing of spin control
 void fireEvent()
          Fires an new ActionEvent to all listeners to notify for changes in SpinControls value.
 void focusGained(java.awt.event.FocusEvent e)
          Just has to be here, because SpinControl implements FocusListener
 void focusLost(java.awt.event.FocusEvent e)
          Fires event to notify all listeners, that SpinControl:s value might have changed
protected  java.lang.String getValueInner()
          Returns spin controls value.
protected abstract  void increase()
          Increase the value of SpinControl
 void setActionCommand(java.lang.String command)
          Sets the actionCommand of this SpinControl
 void setEnabled(boolean enabled)
          Enables or disables this SpinControl
 void setMaximumSize(java.awt.Dimension dimension)
          Set's dimensions of spin controls components to match given maximum dimension
 void setMinimumSize(java.awt.Dimension dimension)
          Set's dimensions of spin controls components to match given minimum dimension
 void setPreferredSize(java.awt.Dimension dimension)
          Set's dimensions of spin controls components to match given preferred dimension
protected  void setValueInner(java.lang.String value)
          Sets spin controls value.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getWidth, getVisibleRect, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setFont, setForeground, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, 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, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpinControl


public SpinControl(javax.swing.text.Document document,
                   java.lang.String initString)
Constructs new SpinControl, assingns a document and initial String for it
Parameters:
document - Document object defining spin controls document format
Method Detail

setPreferredSize


public void setPreferredSize(java.awt.Dimension dimension)
Set's dimensions of spin controls components to match given preferred dimension
Overrides:
setPreferredSize in class javax.swing.JComponent
Parameters:
dimension - Dimension object defining preferred size of whole spin control

setMaximumSize


public void setMaximumSize(java.awt.Dimension dimension)
Set's dimensions of spin controls components to match given maximum dimension
Overrides:
setMaximumSize in class javax.swing.JComponent
Parameters:
dimension - Dimension object defining maximum size of whole spin control

setMinimumSize


public void setMinimumSize(java.awt.Dimension dimension)
Set's dimensions of spin controls components to match given minimum dimension
Overrides:
setMinimumSize in class javax.swing.JComponent
Parameters:
dimension - Dimension object defining minimum size of whole spin control

setValueInner


protected void setValueInner(java.lang.String value)
Sets spin controls value. Accepts only String and forces child to write separate function that uses this one and allows public modification on spin controls value.
Parameters:
value - new value of this spin control

getValueInner


protected java.lang.String getValueInner()
Returns spin controls value. Returns String and forces child to write separate function that uses this one and allows public access to spin controls value.

actionPerformed


public void actionPerformed(java.awt.event.ActionEvent e)
Handles increase and decrease-buttons by calling increase() or decrease() Fires also event notifying all listeners of change in SpinControls value.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - ActionEvent caught

focusGained


public void focusGained(java.awt.event.FocusEvent e)
Just has to be here, because SpinControl implements FocusListener
Specified by:
focusGained in interface java.awt.event.FocusListener
Parameters:
e - FocusEvent caught

focusLost


public void focusLost(java.awt.event.FocusEvent e)
Fires event to notify all listeners, that SpinControl:s value might have changed
Specified by:
focusLost in interface java.awt.event.FocusListener
Parameters:
e - FocusEvent caught

addActionListener


public void addActionListener(java.awt.event.ActionListener listener)
Adds action listener to spin controls textField
Parameters:
listener - ActionListener added

setActionCommand


public void setActionCommand(java.lang.String command)
Sets the actionCommand of this SpinControl
Parameters:
comman - New actionCommand of this SpinControl

setEnabled


public void setEnabled(boolean enabled)
Enables or disables this SpinControl
Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
enabled - boolean telling either to enable (true) or disable (false) spin control

editAllowed


public void editAllowed(boolean enabled)
Enables or disables direct editing of spin control
Parameters:
enabled - boolean telling either to enable (true) or disable (false) spin control

fireEvent


public void fireEvent()
Fires an new ActionEvent to all listeners to notify for changes in SpinControls value.

increase


protected abstract void increase()
Increase the value of SpinControl

decrease


protected abstract void decrease()
Decrease the value of SpinControl