tnt.gui
Class KeyLetterDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by tnt.gui.KeyLetterDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class KeyLetterDialog
extends javax.swing.JDialog
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener

Encapsulates a technique to allow users to map letters to key, but to also restrict their input to valid selections.

Version:
1.0 - 01/2006
Author:
Steven J. Castellucci
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JRadioButton bothThumbs
           
protected  javax.swing.JButton cancelButton
           
protected  javax.swing.JCheckBox[] chkBoxes
           
protected  javax.swing.JTextField idField
           
protected  java.lang.StringBuilder keys
           
protected  javax.swing.JRadioButton leftThumb
           
protected  javax.swing.JRadioButton letterKey
           
static java.lang.String LETTERS
          Each character in this string represents a letter or function that must be mapped.
protected  javax.swing.JRadioButton nextKey
           
protected  javax.swing.JButton okButton
           
protected  javax.swing.JRadioButton rightThumb
           
protected  javax.swing.JRadioButton spaceKey
           
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
KeyLetterDialog(java.awt.Frame owner)
          Initializes the modal dialog.
KeyLetterDialog(java.awt.Frame owner, java.lang.String mapping)
          Initializes the dialog with the passed mapping and makes it modal to its owner.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
           
 void deleteKey(char keyID)
          Deletes mappings associated with the passed key id.
 java.lang.String getChars()
          Returns the characters mapped to the last defined key.
 char getKeyID()
          Returns the key id of the last defined key.
 java.lang.String getKeyMapping()
          Each character in the returned string represents a key id, whose key is mapped to the corresponding letter or function in LETTERS at the same index.
 int getThumb()
          Returns an integer representing the thumb assigned to the last defined key.
 void itemStateChanged(java.awt.event.ItemEvent e)
           
 java.lang.String notMapped()
          Returns letters and functions (i.e., NEXT and SPACE) that have not yet been mapped to keys.
 void setMapping(java.lang.String mapping)
          Sets the key-letter mapping to the passed parameter.
 void setVisible(boolean b)
          Displays or hides this dialog.
 void setVisible(boolean b, KeyButton key)
          Displays or hides this dialog.
 void windowActivated(java.awt.event.WindowEvent we)
           
 void windowClosed(java.awt.event.WindowEvent we)
           
 void windowClosing(java.awt.event.WindowEvent we)
           
 void windowDeactivated(java.awt.event.WindowEvent we)
           
 void windowDeiconified(java.awt.event.WindowEvent we)
           
 void windowIconified(java.awt.event.WindowEvent we)
           
 void windowOpened(java.awt.event.WindowEvent we)
           
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LETTERS

public static final java.lang.String LETTERS
Each character in this string represents a letter or function that must be mapped.

See Also:
Constant Field Values

keys

protected java.lang.StringBuilder keys

letterKey

protected javax.swing.JRadioButton letterKey

nextKey

protected javax.swing.JRadioButton nextKey

spaceKey

protected javax.swing.JRadioButton spaceKey

leftThumb

protected javax.swing.JRadioButton leftThumb

rightThumb

protected javax.swing.JRadioButton rightThumb

bothThumbs

protected javax.swing.JRadioButton bothThumbs

chkBoxes

protected javax.swing.JCheckBox[] chkBoxes

idField

protected javax.swing.JTextField idField

okButton

protected javax.swing.JButton okButton

cancelButton

protected javax.swing.JButton cancelButton
Constructor Detail

KeyLetterDialog

public KeyLetterDialog(java.awt.Frame owner)
Initializes the modal dialog.

Parameters:
owner - the frame to which this dialog is modal.

KeyLetterDialog

public KeyLetterDialog(java.awt.Frame owner,
                       java.lang.String mapping)
Initializes the dialog with the passed mapping and makes it modal to its owner.

Parameters:
owner - the frame to which this dialog is modal.
mapping - an existing mapping to use (i.e., one from a saved file).
Method Detail

setMapping

public void setMapping(java.lang.String mapping)
Sets the key-letter mapping to the passed parameter. (Used primarily by the undo manager and when loading workspaces.)

Parameters:
mapping - the key-letter mapping to set.

setVisible

public void setVisible(boolean b)
Displays or hides this dialog.

Overrides:
setVisible in class java.awt.Component
Parameters:
b - pass true to show, false to hide.

setVisible

public void setVisible(boolean b,
                       KeyButton key)
Displays or hides this dialog.

Parameters:
b - pass true to show, false to hide.
key - pass null for a new key, or pass the object represeting an existing key to edit it.

deleteKey

public void deleteKey(char keyID)
Deletes mappings associated with the passed key id.

Parameters:
keyID - the key whose mappings will be deleted.

getKeyID

public char getKeyID()
Returns the key id of the last defined key. Returns the empty character if no mapping was committed (i.e., the user cancelled or closed the dialog).

Returns:
the key id of the last defined key.

getChars

public java.lang.String getChars()
Returns the characters mapped to the last defined key. Returns the empty string if no mapping was committed (i.e., the user cancelled or closed the dialog).

Returns:
the characters mapped to the last defined key.

getThumb

public int getThumb()
Returns an integer representing the thumb assigned to the last defined key.

Returns:
the thumb assigned to the last defined key.
See Also:
KeyButton.LEFT_THUMB, KeyButton.RIGHT_THUMB, KeyButton.BOTH_THUMBS

notMapped

public java.lang.String notMapped()
Returns letters and functions (i.e., NEXT and SPACE) that have not yet been mapped to keys.

Returns:
all letters and functions not yet mapped.

getKeyMapping

public java.lang.String getKeyMapping()
Each character in the returned string represents a key id, whose key is mapped to the corresponding letter or function in LETTERS at the same index.

Returns:
the String value of the variable keys.

actionPerformed

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

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent we)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent we)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent we)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent we)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent we)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent we)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent we)
Specified by:
windowOpened in interface java.awt.event.WindowListener


Copyright © 2006 Steven Castellucci and Scott MacKenzie. All Rights Reserved.