|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.util.MnemonicSolver
This class can be used to resolve mnemonic conflicts in menus. The class
manages a list of MnemonicSolver.MenuLabel
recording all labels
whose mnemonics need to be resolved.
To use the mnemonic solver class you create a instance of the solver,
you then add a pull down menu, popup menu, or individual menu items
to the solver. Once all menu items are added you just call the
solve()
method to put this class to work.
The registered menu items may have their mnemonics changed when the
solve()
method is executed.
Nested Class Summary | |
class |
MnemonicSolver.MenuLabel
MenuLabel class. |
Constructor Summary | |
MnemonicSolver()
Default Constructor. |
|
MnemonicSolver(javax.swing.JMenu menu)
Constructor. |
|
MnemonicSolver(javax.swing.JPopupMenu popupMenu)
Constructor. |
|
MnemonicSolver(java.lang.String[] labels)
Constructor. |
|
MnemonicSolver(java.lang.String[] labels,
int[] mnemonics)
Constructor. |
|
MnemonicSolver(java.lang.String[] labels,
int[] mnemonics,
boolean[] fixed)
Constructor. |
Method Summary | |
MnemonicSolver.MenuLabel |
addMenuLabel(java.awt.Component component,
boolean fixed)
If the specified component is a JMenuItem it
adds it to the list of menu items whose mnemonic needs be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(java.awt.Component component,
java.lang.String text,
boolean fixed)
If the specified component is a JMenuItem it
adds it to the list of menu items whose mnemonic needs be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(javax.swing.JMenuItem menuItem)
Adds a new menuItem to the list of menu items whose
mnemonic needs be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(javax.swing.JMenuItem menuItem,
boolean fixed)
Adds a new menuItem to the list of menu items whose
mnemonic needs be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(javax.swing.JMenuItem menuItem,
java.lang.String text,
boolean fixed)
Adds a new menuItem to the list of menu items whose
mnemonic needs be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(java.lang.String text)
Adds a new menu label to the list of labels whose mnemonics need to be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(java.lang.String text,
int mnemonic)
Adds a new menu label to the list of labels whose mnemonic needs to be resolved. |
MnemonicSolver.MenuLabel |
addMenuLabel(java.lang.String text,
int mnemonic,
boolean fixed)
Adds a new menu label to the list of labels whose mnemonic needs to be resolved. |
java.util.Collection |
addMenuLabels(javax.swing.JMenu menu)
Adds all menu items contained in the specified menu to
the list of items whose mnemonic needs resolution. |
java.util.Collection |
addMenuLabels(javax.swing.JPopupMenu popupMenu)
Adds all menu items contained in the specified popupMenu to
the list of items whose mnemonic needs resolution. |
void |
clear()
Clear the list of menu labels registered for resolution. |
MnemonicSolver.MenuLabel |
findMenuLabel(javax.swing.JMenuItem menuItem)
Returns the MnemonicSolver.MenuLabel associated with the specified
menuItem . |
void |
removeMenuLabel(MnemonicSolver.MenuLabel label)
Unregister the specified menu label . |
java.util.Collection |
solve()
Solves mnemonic conflics. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MnemonicSolver()
public MnemonicSolver(java.lang.String[] labels)
labels
- An array of strings representing the menu labels.public MnemonicSolver(java.lang.String[] labels, int[] mnemonics)
labels
- An array of strings representing the menu labels.mnemonics
- An array of integers representing the correspoding label
mnemonic. The length of the array must be the same as the length of the
labels
array.public MnemonicSolver(java.lang.String[] labels, int[] mnemonics, boolean[] fixed)
labels
- An array of strings representing the menu labels.mnemonics
- An array of integers representing the correspoding label
mnemonic. The length of the array must be the same as the length of the
labels
array.fixed
- An array of booleans indicating whether the correspoding
mnemonic cannot be changed. The length of the array must be the same as
the length of the labels
array.public MnemonicSolver(javax.swing.JMenu menu)
menu
- A menu containing menu items.public MnemonicSolver(javax.swing.JPopupMenu popupMenu)
popupMenu
- A popup menu containing menu items.Method Detail |
public MnemonicSolver.MenuLabel addMenuLabel(java.lang.String text)
public MnemonicSolver.MenuLabel addMenuLabel(java.lang.String text, int mnemonic)
mnemonic
is the suggested
mnemonic for the label. If conflicts exist, the suggested mnemonic
may not be used.
public MnemonicSolver.MenuLabel addMenuLabel(java.lang.String text, int mnemonic, boolean fixed)
mnemonic
is the suggested
mnemonic for the label. If the parameter fixed
is
specified as true
, the suggested mnemonic will be used
unless the same mnemonic is also fixed by another menu. In this case
the menu with smaller number of characters will have preference in
using the specified mnemonic.
public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.JMenuItem menuItem)
menuItem
to the list of menu items whose
mnemonic needs be resolved. The menu item mnemonic, if set, is used
as the suggested mnemonic for the menu label. If conflicts exist, the
suggested mnemonic may not be used.
public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.JMenuItem menuItem, boolean fixed)
menuItem
to the list of menu items whose
mnemonic needs be resolved. The menu item mnemonic, if set, is used
as the suggested mnemonic for the menu label. If the parameter
fixed
is specified as true
, the suggested
mnemonic will be used unless the same mnemonic is also fixed by
another menu. In this case the menu with smaller number of
characters will have preference in using the specified mnemonic.
If the specified menuItem
is already registered this
method will only set the given fixed
value.
public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.JMenuItem menuItem, java.lang.String text, boolean fixed)
menuItem
to the list of menu items whose
mnemonic needs be resolved. The menu item mnemonic, if set, is used
as the suggested mnemonic for the menu label. If the text
parameter is specified it overrides the menuItem
text.
If the parameter fixed
is specified as true
,
the suggested mnemonic will be used unless the same mnemonic is also
fixed by another menu. In this case the menu with smaller number of
characters will have preference in using the specified mnemonic.
If the specified menuItem
is already registered this
method will only set the given fixed
value.
public MnemonicSolver.MenuLabel addMenuLabel(java.awt.Component component, boolean fixed)
component
is a JMenuItem
it
adds it to the list of menu items whose mnemonic needs be resolved.
The menu item mnemonic, if set, is used as the suggested mnemonic for
the menu label. If the parameter fixed
is specified as
true
, the suggested mnemonic will be used unless the same
mnemonic is also fixed by another menu. In this case the menu with
smaller number of characters will have preference in using the specified
mnemonic.
If the specified menuItem
is already registered this
method will only set the given fixed
value.
public MnemonicSolver.MenuLabel addMenuLabel(java.awt.Component component, java.lang.String text, boolean fixed)
component
is a JMenuItem
it
adds it to the list of menu items whose mnemonic needs be resolved.
The menu item mnemonic, if set, is used as the suggested mnemonic for
the menu label. If the text
parameter is specified it
overrides the menuItem
text. If the parameter
fixed
is specified as true
,
the suggested mnemonic will be used unless the same mnemonic is also
fixed by another menu. In this case the menu with smaller number of
characters will have preference in using the specified mnemonic.
If the specified menuItem
is already registered this
method will only set the given fixed
value.
public java.util.Collection addMenuLabels(javax.swing.JMenu menu)
menu
to
the list of items whose mnemonic needs resolution.
public java.util.Collection addMenuLabels(javax.swing.JPopupMenu popupMenu)
popupMenu
to
the list of items whose mnemonic needs resolution.
public MnemonicSolver.MenuLabel findMenuLabel(javax.swing.JMenuItem menuItem)
MnemonicSolver.MenuLabel
associated with the specified
menuItem
. If none found, null
is returned.
public void removeMenuLabel(MnemonicSolver.MenuLabel label)
label
.
public java.util.Collection solve()
Collection
holding the solved menu labels.public void clear()
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.