gui.run
Class ShortcutUtils

java.lang.Object
  extended by gui.run.ShortcutUtils

public class ShortcutUtils
extends java.lang.Object


Field Summary
static char LEFT_BRACE
           
static char META_CHARACTER
           
static char RIGHT_BRACE
           
 
Constructor Summary
ShortcutUtils()
           
 
Method Summary
static void addAccelerator(javax.swing.JMenuItem jmi)
          Accelerator strings are embedded in the label of a JMenuItem.
static void addFocusAccelerator(java.lang.String label, javax.swing.JTextField tf)
          Adds the accelerator without altering textfield contents.
static void addShortcut(javax.swing.AbstractButton ab)
          "this is a shortcut [c" "this has no shortcut [" "this has no shortcut either"
static void addShortcut(java.awt.Button ab)
          "this is a shortcut [c" "this has no shortcut [" "this has no shortcut either"
static void addShortcut(javax.swing.JLabel tf)
          add a short cut to a label so that you can tab over to the corresponding text field.
static void addShortcut(javax.swing.JTabbedPane jtp)
          This was supposed to search the tab list and add mnemonics, but, for some reason, it does not work.
static void addShortcut(javax.swing.JTextField tf)
          add a short-cut to a text field so you can tab over to the field
static void addShortcut(RunMenu menu)
           
static void addShortcut(RunMenuItem item)
           
static java.lang.String getAcceleratorString(java.lang.String s)
          get the embedded keyboard accelerator string.
static javax.swing.KeyStroke getKeyStroke(java.lang.String s)
          get the key stroke that corresponds to the give keyboard accelerator.
static char getMnemonicChar(java.lang.String s)
          return the char next to the '['
static boolean hasAccelerator(java.lang.String s)
           
static boolean hasShortcut(java.lang.String s)
           
static void main(java.lang.String[] args)
           
static java.lang.String stripAcceleratorString(java.lang.String s)
          remote the left brace from the string and make upper case.
static java.lang.String stripMnemonicMetaChar(java.lang.String s)
          Strip the meta character '[' and return the remaining string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META_CHARACTER

public static final char META_CHARACTER
See Also:
Constant Field Values

LEFT_BRACE

public static final char LEFT_BRACE
See Also:
Constant Field Values

RIGHT_BRACE

public static final char RIGHT_BRACE
See Also:
Constant Field Values
Constructor Detail

ShortcutUtils

public ShortcutUtils()
Method Detail

hasAccelerator

public static boolean hasAccelerator(java.lang.String s)
Parameters:
s -
Returns:
true if there is a left and right brace in the label.

hasShortcut

public static boolean hasShortcut(java.lang.String s)
Parameters:
s -
Returns:
returns true if there is no META_CHARACTER '[' and no KEYSTRING_START and no KEYSTRING_END. E.g. no "{...}" pair.

getMnemonicChar

public static char getMnemonicChar(java.lang.String s)
return the char next to the '['

Parameters:
s -
Returns:
char next to the '['

getAcceleratorString

public static java.lang.String getAcceleratorString(java.lang.String s)
get the embedded keyboard accelerator string. This is typically surrounded with '{}''s

Parameters:
s -
Returns:
String surrounded with '{}'

getKeyStroke

public static javax.swing.KeyStroke getKeyStroke(java.lang.String s)
get the key stroke that corresponds to the give keyboard accelerator.

Parameters:
s -
Returns:
corresponding key stroke

stripMnemonicMetaChar

public static java.lang.String stripMnemonicMetaChar(java.lang.String s)
Strip the meta character '[' and return the remaining string

Parameters:
s -
Returns:
string without mnemonic

stripAcceleratorString

public static java.lang.String stripAcceleratorString(java.lang.String s)
remote the left brace from the string and make upper case.

Parameters:
s -
Returns:
string without left brace

addShortcut

public static void addShortcut(javax.swing.JTabbedPane jtp)
This was supposed to search the tab list and add mnemonics, but, for some reason, it does not work. This is the bug 4624207 http://developer.java.sun.com/developer/bugParade/bugs/4624207.html and it was fixed in 1.5

Parameters:
jtp -

addShortcut

public static void addShortcut(java.awt.Button ab)
"this is a shortcut [c" "this has no shortcut [" "this has no shortcut either"

Parameters:
ab -

addShortcut

public static void addShortcut(javax.swing.AbstractButton ab)
"this is a shortcut [c" "this has no shortcut [" "this has no shortcut either"

Parameters:
ab -

addShortcut

public static void addShortcut(javax.swing.JTextField tf)
add a short-cut to a text field so you can tab over to the field

Parameters:
tf -

addShortcut

public static void addShortcut(javax.swing.JLabel tf)
add a short cut to a label so that you can tab over to the corresponding text field. It is for display, only.

Parameters:
tf -

addFocusAccelerator

public static void addFocusAccelerator(java.lang.String label,
                                       javax.swing.JTextField tf)
Adds the accelerator without altering textfield contents. This does NOT alter the appearance of the textfield, it only sets the accelerator. Also, the label is used as the tool tip text.

Parameters:
label - label upon which accelerator is based.
tf - textfield to which accelerator is to be added.

addAccelerator

public static void addAccelerator(javax.swing.JMenuItem jmi)
Accelerator strings are embedded in the label of a JMenuItem. For example: "my label{alt shift X} "another label {control DELETE} works on JCheckBoxMenuItem and JRadioButtonMenuItem

Parameters:
jmi -

main

public static void main(java.lang.String[] args)

addShortcut

public static void addShortcut(RunMenuItem item)

addShortcut

public static void addShortcut(RunMenu menu)