QJCC homepage

biz.chitec.quarterback.swing
Class KeyStrokeReader

java.lang.Object
  extended bybiz.chitec.quarterback.swing.KeyStrokeReader
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener

public class KeyStrokeReader
extends java.lang.Object
implements java.awt.event.KeyListener

Reads key strokes direcly from the keyboard. This class can be used to define key strokes for shortcuts etc. directly from the keyboard. It opens a modal JOptionPane and lets the user enter the key stroke. readKeyStroke() returns the complete key stroke which has been entered or null if nothing has been entered or the entered key stroke has not been confirmed.

Version:
$Id: 67886ecdd2e581bd633bc83dadd0a1e93bc0c374 $
Author:
cantamen/Dirk Hillbrecht 2007

Field Summary
private  javax.swing.JDialog dlg
           
private  boolean finished
           
private  javax.swing.JOptionPane jop
           
private  javax.swing.JPanel jp
           
private  javax.swing.JLabel lbl
           
private  int modifier
           
private static QuickIntArray modifierkeys
           
private  java.util.ResourceBundle rb
           
private  javax.swing.JTextField showlabel
           
private  int vk
           
 
Constructor Summary
KeyStrokeReader(java.awt.Component parent)
          Define the reader as descendant from a certain component.
 
Method Summary
 void keyPressed(java.awt.event.KeyEvent e)
          Internal method for key event handling.
 void keyReleased(java.awt.event.KeyEvent e)
          Internal method for key event handling.
static java.lang.String keyStrokeToString(javax.swing.KeyStroke ks)
          Reduced emulation of Java 1.5 code for Java 1.4 environments.
 void keyTyped(java.awt.event.KeyEvent e)
          Internal method for key event handling.
 javax.swing.KeyStroke readKeyStroke()
          Show the reader dialog and return the entered key stroke.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modifierkeys

private static QuickIntArray modifierkeys

jop

private javax.swing.JOptionPane jop

dlg

private javax.swing.JDialog dlg

lbl

private javax.swing.JLabel lbl

showlabel

private javax.swing.JTextField showlabel

jp

private javax.swing.JPanel jp

finished

private boolean finished

modifier

private int modifier

vk

private int vk

rb

private java.util.ResourceBundle rb
Constructor Detail

KeyStrokeReader

public KeyStrokeReader(java.awt.Component parent)
Define the reader as descendant from a certain component. The component is only important because the dialog window will align itself to this component.

Parameters:
parent - Component to align the dialog window to
Method Detail

readKeyStroke

public javax.swing.KeyStroke readKeyStroke()
Show the reader dialog and return the entered key stroke. Calling this method opens a modal dialog and lets the user enter the key stroke. The method will only return after the input dialog has been closed.

Returns:
Entered key stroke or null if nothing has been entered and confirmed

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Internal method for key event handling.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Internal method for key event handling.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Internal method for key event handling.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyStrokeToString

public static java.lang.String keyStrokeToString(javax.swing.KeyStroke ks)
Reduced emulation of Java 1.5 code for Java 1.4 environments.


QJCC homepage