Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.ide.util
Class MnemonicSolver

java.lang.Object
  extended by oracle.ide.util.MnemonicSolver


public class MnemonicSolver
extends java.lang.Object

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(javax.swing.AbstractButton menuItem)
          Adds a new menuItem to the list of menu items whose mnemonic needs be resolved.
 MnemonicSolver.MenuLabel addMenuLabel(javax.swing.AbstractButton menuItem, boolean fixed)
          Adds a new menuItem to the list of menu items whose mnemonic needs be resolved.
 MnemonicSolver.MenuLabel addMenuLabel(javax.swing.AbstractButton 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.awt.Component component, boolean fixed)
          If the specified component is a AbstractButton 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 AbstractButton 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.AbstractButton menuItem)
          Returns the MnemonicSolver.MenuLabel associated with the specified menuItem.
 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

MnemonicSolver

public MnemonicSolver()
Default Constructor.

MnemonicSolver

public MnemonicSolver(java.lang.String[] labels)
Constructor.
Parameters:
labels - An array of strings representing the menu labels.

MnemonicSolver

public MnemonicSolver(java.lang.String[] labels,
                      int[] mnemonics)
Constructor.
Parameters:
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.

MnemonicSolver

public MnemonicSolver(java.lang.String[] labels,
                      int[] mnemonics,
                      boolean[] fixed)
Constructor.
Parameters:
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.

MnemonicSolver

public MnemonicSolver(javax.swing.JMenu menu)
Constructor. When a menu contains submenus, those submenus must be resolved individually.
Parameters:
menu - A menu containing menu items.

MnemonicSolver

public MnemonicSolver(javax.swing.JPopupMenu popupMenu)
Constructor. When a menu contains submenus, those submenus must be resolved individually.
Parameters:
popupMenu - A popup menu containing menu items.

Method Detail

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(java.lang.String text)
Adds a new menu label to the list of labels whose mnemonics need to be resolved.

addMenuLabel

public 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. The specified mnemonic is the suggested mnemonic for the label. If conflicts exist, the suggested mnemonic may not be used.

addMenuLabel

public 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. The specified 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.AbstractButton menuItem)
Adds a new 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.JMenuItem menuItem)
Adds a new 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.AbstractButton menuItem,
                                             boolean fixed)
Adds a new 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.JMenuItem menuItem,
                                             boolean fixed)
Adds a new 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(javax.swing.AbstractButton menuItem,
                                             java.lang.String text,
                                             boolean fixed)
Adds a new 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.

addMenuLabel

public 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. 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(java.awt.Component component,
                                             boolean fixed)
If the specified component is a AbstractButton 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.

addMenuLabel

public MnemonicSolver.MenuLabel addMenuLabel(java.awt.Component component,
                                             java.lang.String text,
                                             boolean fixed)
If the specified component is a AbstractButton 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.

addMenuLabels

public 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.

addMenuLabels

public 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.

findMenuLabel

public MnemonicSolver.MenuLabel findMenuLabel(javax.swing.AbstractButton menuItem)
Returns the MnemonicSolver.MenuLabel associated with the specified menuItem. If none found, null is returned.

findMenuLabel

public MnemonicSolver.MenuLabel findMenuLabel(javax.swing.JMenuItem menuItem)
Returns the MnemonicSolver.MenuLabel associated with the specified menuItem. If none found, null is returned.

removeMenuLabel

public void removeMenuLabel(MnemonicSolver.MenuLabel label)
Unregister the specified menu label.

solve

public java.util.Collection solve()
Solves mnemonic conflics.
Returns:
A Collection holding the solved menu labels.

clear

public void clear()
Clear the list of menu labels registered for resolution.

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.