|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.as400.ui.framework.java.MenuManager
public class MenuManager extends Object
Creates a menu defined using the Panel Definition Markup Language (PDML).
MenuManager performs the following processing on behalf
of the application:
ActionHandlers
specified in the PDML with the appropriate menu items.
To locate a menu definition, MenuManager needs three pieces of information:
MENU
tag in the PDML.
The framework first searches the specified location for a file with a name matching
the menu name, and an extension of .pdml.ser. If the serialized
menu definition is not found, an attempt will be made to load a ResourceBundle
and a PDML file which correspond to the specified resource name. If the resources cannot
be located a DisplayManagerException will be thrown.
MyMenu is defined in the file TestPanels.pdml,
and that a properties file TestPanels.properties is associated with the menu
definition. Both files reside in the directory com/ourCompany/ourPackage,
which is accessible from a directory defined in the classpath, or from a ZIP or JAR file
defined in the classpath. The following code creates the menu and adds it to the
menu bar for an application's dialog window:
import com.ibm.as400.ui.framework.java.*;
// Create the menu manager. Parameters:
// 1. Resource name of the menu definition
// 2. Name of menu
// 3. Pane manager not needed
MenuManager mm = null;
try {
mm = new MenuManager("com.ourCompany.ourPackage.TestPanels",
"Mymenu",
null);
}
catch (DisplayManagerException e) {
e.displayUserMessage(null);
System.exit(-1);
}
// Add the menu to a menu bar
JMenuBar jmb = new JMenuBar();
jmb.add(mm.getMenu());
java com.ibm.as400.ui.framework.java.MenuManager
[-serialize]
[-locale <language code>_<country or region code>_<variant>]
<resource name>
<menu name>
Options:
.pdml.ser.
If this option is specified the menu will not be displayed on the screen.
menu
tag in the PDML document.
Examples:
java com.ibm.as400.ui.framework.java.MenuManager com.ourCompany.ourPackage.TestPanels MyMenu
java com.ibm.as400.ui.framework.java.MenuManager -serialize com.ourCompany.ourPackage.TestPanels MyMenu
java com.ibm.as400.ui.framework.java.MenuManager -locale en_UK com.ourCompany.ourPackage.TestPanels MyMenu
java com.ibm.as400.ui.framework.java.MenuManager -serialize -locale en_UK com.ourCompany.ourPackage.TestPanels MyMenu
DisplayManagerException| Constructor and Description |
|---|
MenuManager(String baseName,
Locale locale,
String menuName)
Constructs a MenuManager object for the specified menu,
and then serializes the menu definition. |
MenuManager(String baseName,
Locale locale,
String menuName,
PaneManager pm)
Constructs a MenuManager for the specified menu. |
MenuManager(String baseName,
String menuName,
PaneManager pm)
Constructs a MenuManager for the specified menu. |
| Modifier and Type | Method and Description |
|---|---|
void |
addMenuItem(JMenuItem mi)
Adds a MenuItem to this MenuManager The MenuItem must have a non-null name |
void |
addSeparator()
Adds a Seperator to this MenuManager |
void |
enableAllMenuItems(boolean b)
Enables or Disables all Menu Items contained in this MenuManager |
void |
enableMenuItem(String name,
boolean b)
Enables or Disables a MenuItem contained in this MenuManager |
Action[] |
getActions()
Returns a list of Actions for the items in this menu. |
JMenu |
getMenu()
Returns the root JMenu for this menu. |
JMenuItem |
getMenuItem(String name)
Returns the menu item identified by name. |
String |
getName()
Returns the this Menu Manager's name |
PaneManager |
getPaneManager()
Returns the PaneManager with which this menu is associated. |
static void |
main(String[] args)
Provides a command line interface to MenuManager. |
void |
removeMenuItem(String name)
Removes a MenuItem |
void |
serialize()
Serializes the menu definition. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MenuManager(String baseName,
String menuName,
PaneManager pm)
throws DisplayManagerException
MenuManager for the specified menu.
The default locale will be used to load the menu definition.
baseName - the resource name of the PDML document/resource bundle combination which defines the menu specificationmenuName - the name of the menu, as specified on the MENU tag in the PDMLthe - PaneManager with which this menu is associated (may be null)DisplayManagerException - if an error was encountered accessing the menu definitionPaneManager,
DisplayManagerException
public MenuManager(String baseName,
Locale locale,
String menuName,
PaneManager pm)
throws DisplayManagerException
MenuManager for the specified menu.
baseName - the resource name of the PDML document/resource bundle combination which defines the menu specificationlocale - the desired locale to be used to load the menu definitionmenuName - the name of the menu, as specified on the MENU tag in the PDMLthe - PaneManager with which this menu is associated (may be null)DisplayManagerException - if an error was encountered accessing the menu definitionPaneManager,
DisplayManagerException
public MenuManager(String baseName,
Locale locale,
String menuName)
throws DisplayManagerException
MenuManager object for the specified menu,
and then serializes the menu definition.
This constructor cannot be used to display the menu.
If a null locale is specified, the default locale will be used to load the menu definition. If resources for the default locale cannot be found, an attempt will be made to use the base resources for the menu.
baseName - the resource name of the PDML document/resource bundle combination which define the menu specificationlocale - the desired locale to be used to load the menu definition (may be null)menuName - the name of the menu, as specified on the MENU tag in the PDMLDisplayManagerException - if an error was encountered accessing or serializing the menu definitionDisplayManagerException,
serialize()| Method Detail |
|---|
public static void main(String[] args)
MenuManager. See the class description.
public void serialize()
throws IOException
<menu name>_<locale string>.pdml.serwhere
<menu name>
is the name of the menu as specified on the MENU
tag in the PDML, and <locale string> consists of the ISO Language Code,
ISO country or region code, and optional variant codes, each delimited by an underscore ("_") character.
IOException - if serialized file cannot be writtenpublic JMenu getMenu()
JMenu for this menu.
JMenu for this menupublic JMenuItem getMenuItem(String name)
name - the name of the menu item as specified in the menu definitionJMenuItem corresponding to the specified menu itempublic void enableAllMenuItems(boolean b)
b - true to enable the menu item
public void enableMenuItem(String name,
boolean b)
name - the name of the menu item be enabledb - true to enable the menu itempublic void addMenuItem(JMenuItem mi)
mi - a named JMenuItempublic void addSeparator()
public void removeMenuItem(String name)
name - the name of the MenuItem to be removedpublic Action[] getActions()
Actions for the items in this menu.
Actions for the menu itemspublic PaneManager getPaneManager()
PaneManager with which this menu is associated.
PaneManager with which this menu is associated (may be null)PaneManagerpublic String getName()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||