org.formaria.swing
Class Keypad

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.formaria.swing.Keypad
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, ErrorDisplay, TextHolder, StateListener

public class Keypad
extends javax.swing.JComponent
implements StateListener, TextHolder, ErrorDisplay

An KeyPad component is a visual representation of a numeric keypad.

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from formaria.

$Revision: 1.12 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int borderHeight
           
protected  int borderWidth
           
protected  ClickListener clickListener
           
protected  Project currentProject
          The owner project and the context in which this object operates.
protected  java.lang.String errorMessage
           
protected  int errorStatus
           
protected  int keyHeight
           
protected  int keyWidth
           
protected  StyleManager styleManager
           
 
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
Keypad()
          Constructor for a new Keypad.
 
Method Summary
 void clear()
          Clears the output value.
 int findCurrentResponse(int x, int y)
          Find the response corresponding to the current point
 java.awt.Color getColor(int idx, int callerClassId)
          Gets an indexed color.
 java.lang.String getStyle3D()
          Get the style asociated with three dimensional objects/elements
 java.lang.String getStyleShade()
          Get the style asociated with shaded elements
 java.lang.String getText()
          Gets the output text
 java.lang.String getValue()
          Gets the output value
 void paint(java.awt.Graphics sg)
          Renders the keypad
 void paintStates()
          Repaint the responses
 boolean respond()
          Called by ClickListener to check if a response event should be sent to the parent form.
 void setErrorMessage(java.lang.String errorMsg)
          Set the error message
 void setErrorStatus(int status)
          Set the error status
 void setMaxLength(int len)
          Sets the maximum length of the output value
 void setMinLength(int len)
          Sets the minimum length of the output value
 void setOutputField(TextHolder of)
          Sets a text field in which to display the key value.
 boolean setState(int x, int y, int defResponse)
          Find a response
 void setStyle(java.lang.String newStyle)
          Set the style asociated with shaded elements, background and text colors
 void setStyle3D(java.lang.String newStyle)
          Get the style asociated with three dimensional objects/elements
 void setStyleShade(java.lang.String newStyle)
          Set the style asociated with shaded elements, frame color
 void setText(java.lang.String newText)
          Sets the control's text.
 void setValue(java.lang.String newValue)
          Sets the output value
 void update(java.awt.Graphics g)
          Refresh the display
 void updateSelectedState()
          Fired the keyPressed event if a button has been pressed
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 

Field Detail

borderHeight

protected int borderHeight

borderWidth

protected int borderWidth

keyHeight

protected int keyHeight

keyWidth

protected int keyWidth

clickListener

protected ClickListener clickListener

styleManager

protected StyleManager styleManager

errorStatus

protected int errorStatus

errorMessage

protected java.lang.String errorMessage

currentProject

protected Project currentProject
The owner project and the context in which this object operates.

Constructor Detail

Keypad

public Keypad()
Constructor for a new Keypad. This control displays a numeric keypad

Method Detail

update

public void update(java.awt.Graphics g)
Refresh the display

Overrides:
update in class javax.swing.JComponent
Parameters:
g - the graphics context

paint

public void paint(java.awt.Graphics sg)
Renders the keypad

Overrides:
paint in class javax.swing.JComponent
Parameters:
sg - the graphics context

paintStates

public void paintStates()
Repaint the responses

Specified by:
paintStates in interface StateListener

setState

public boolean setState(int x,
                        int y,
                        int defResponse)
Find a response

Specified by:
setState in interface StateListener
Parameters:
x - the x coordinate of the mouse click
y - the y coordinate of the mouse click
defResponse - the default response
Returns:
true if a response was found

findCurrentResponse

public int findCurrentResponse(int x,
                               int y)
Find the response corresponding to the current point

Specified by:
findCurrentResponse in interface StateListener
Parameters:
x - the x coordinate of the mouse click
y - the y coordinate of the mouse click
Returns:
the response value if the mouse were click at the specified location, or -1 if not selection is available

updateSelectedState

public void updateSelectedState()
Fired the keyPressed event if a button has been pressed

Specified by:
updateSelectedState in interface StateListener

respond

public boolean respond()
Called by ClickListener to check if a response event should be sent to the parent form. The control can also use this event to do post click processing

Returns:
true if the parent is to be notified

getColor

public java.awt.Color getColor(int idx,
                               int callerClassId)
Gets an indexed color.

Parameters:
idx - The index of the color to get.
callerClassId - The ID of this calling class
Returns:
The color
See Also:
org.formaria.miniui.Frame#X_BUTTON

getStyle3D

public java.lang.String getStyle3D()
Get the style asociated with three dimensional objects/elements

Returns:
the style name

getStyleShade

public java.lang.String getStyleShade()
Get the style asociated with shaded elements

Returns:
the style name

setStyle

public void setStyle(java.lang.String newStyle)
Set the style asociated with shaded elements, background and text colors

Parameters:
newStyle - the style name

setStyle3D

public void setStyle3D(java.lang.String newStyle)
Get the style asociated with three dimensional objects/elements

Parameters:
newStyle - the style name

setStyleShade

public void setStyleShade(java.lang.String newStyle)
Set the style asociated with shaded elements, frame color

Parameters:
newStyle - the style name

setText

public void setText(java.lang.String newText)
Sets the control's text. Used to localize the control.

Specified by:
setText in interface TextHolder
Parameters:
newText - The new text to display.

setOutputField

public void setOutputField(TextHolder of)
Sets a text field in which to display the key value.

Parameters:
of - the output text field

clear

public void clear()
Clears the output value.


getValue

public java.lang.String getValue()
Gets the output value

Returns:
the keyped value

getText

public java.lang.String getText()
Gets the output text

Specified by:
getText in interface TextHolder
Returns:
the keyped text

setValue

public void setValue(java.lang.String newValue)
Sets the output value

Parameters:
newValue - the new keypad value

setMaxLength

public void setMaxLength(int len)
Sets the maximum length of the output value

Parameters:
len - the new maximum length

setMinLength

public void setMinLength(int len)
Sets the minimum length of the output value

Parameters:
len - the new minimum length

setErrorStatus

public void setErrorStatus(int status)
Set the error status

Specified by:
setErrorStatus in interface ErrorDisplay
Parameters:
status -

setErrorMessage

public void setErrorMessage(java.lang.String errorMsg)
Set the error message

Specified by:
setErrorMessage in interface ErrorDisplay
Parameters:
errorMsg - the message text