All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.ui.framework.java.ContextMenuManager

java.lang.Object
   |
   +----com.ibm.as400.ui.framework.java.MenuManager
           |
           +----com.ibm.as400.ui.framework.java.ContextMenuManager

public class ContextMenuManager
extends MenuManager
Creates a context menu defined using the Panel Definition Markup Language (PDML).

ContextMenuManager performs the following processing on behalf of the application:

To locate a menu definition, ContextMenuManager needs three pieces of information:

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.

Examples

Assume that the context menu MyMenu is defined in the file TestMenus.pdml, and that a properties file TestMenus.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 context menu and displays it:

 import com.ibm.as400.ui.framework.java.*;
  
 // Create the context menu manager. Parameters:
 // 1. Resource name of the menu definition
 // 2. Name of menu
 // 3. PaneManager managing the window currently displayed (may be null)
  
 MenuManager mm = null;
 try {
 mm = new MenuManager("com.ourCompany.ourPackage.TestMenus",
                      "Mymenu",
                      null);
 }
 catch (DisplayManagerException e) {
 e.displayUserMessage(null);
 System.exit(-1);
 }
 ...
 // Display the context menu (normally done when handling a mouse event).
 MouseEvent e;
 mm.show(e.getComponent(), e.getX(), e.getY());
 

Command Line Interface

The command line interface may be used to display newly-defined menus.
 java com.ibm.as400.ui.framework.java.MenuManager
     [-locale <language code>_<country code>_<variant>]
     <resource name>
     <context menu name>
 
Options:

-locale <language code>_<country code>_<variant>
Identifies the locale which should be used to locate the menu definition. The locale string should consist of a two-letter lowercase ISO Language Code, a two-letter uppercase ISO country code, and an optional variant string, each delimited by an underscore ("_") character. If this parameter is omitted the default locale will be used. If resources for the default locale cannot be found, an attempt will be made to use the base resources for the menu.

<resource name>
The fully-qualified resource name of the PDML document/resource bundle combination which defines the menu specification.

<context menu name>
The name of the menu, as specified on the menu tag in the PDML document.

Examples:

Test a base sample menu:

java com.ibm.as400.ui.framework.java.MenuManager com.ourCompany.ourPackage.Testmenus Mymenu

Test the UK version:

java com.ibm.as400.ui.framework.java.MenuManager -locale en_UK com.ourCompany.ourPackage.Testmenus Mymenu

See Also:
DisplayManagerException

Constructor Index

 o ContextMenuManager(String, Locale, String, PaneManager)
Constructs a ContextMenuManager for the specified menu.
 o ContextMenuManager(String, String, PaneManager)
Constructs a ContextMenuManager for the specified menu.

Method Index

 o getLocation()
Returns the location of this context menu.
 o isVisible()
Determines whether this context menu is visible.
 o main(String[])
Provides a command line interface to ContextMenuManager.
 o setLocation(Point)
Sets the location of this context menu.
 o setVisible(boolean)
Shows or hides this context menu based on the value of parameter visible.
 o show(Component, int, int)
Displays this context menu at the position x,y in the coordinate space of the specified invoker.

Constructors

 o ContextMenuManager
 public ContextMenuManager(String baseName,
                           String menuName,
                           PaneManager pm) throws DisplayManagerException
Constructs a ContextMenuManager for the specified menu.

The default locale will be used to load the menu definition.

Parameters:
baseName - the resource name of the PDML document/resource bundle combination which defines the menu specification
menuName - the name of the menu, as specified on the MENU tag in the PDML
pm - the PaneManager managing the window on which the context menu will be displayed (may be null)
Throws: DisplayManagerException
if an error was encountered accessing the menu definition
See Also:
PaneManager, DisplayManagerException
 o ContextMenuManager
 public ContextMenuManager(String baseName,
                           Locale locale,
                           String menuName,
                           PaneManager pm) throws DisplayManagerException
Constructs a ContextMenuManager for the specified menu.

Parameters:
baseName - the resource name of the PDML document/resource bundle combination which defines the menu specification
locale - the desired locale to be used to load the menu definition
menuName - the name of the menu, as specified on the MENU tag in the PDML
pm - the PaneManager managing the window on which the context menu will be displayed (may be null)
Throws: DisplayManagerException
if an error was encountered accessing the menu definition
See Also:
PaneManager, DisplayManagerException

Methods

 o main
 public static void main(String args[])
Provides a command line interface to ContextMenuManager. See the class description.

 o setLocation
 public void setLocation(Point pt)
Sets the location of this context menu.

Parameters:
pt - a Point identifying the location of the top left corner of the context menu
 o getLocation
 public Point getLocation()
Returns the location of this context menu.

Returns:
pt a Point identifying the location of the top left corner of the context menu
 o setVisible
 public void setVisible(boolean visible)
Shows or hides this context menu based on the value of parameter visible.

Parameters:
visible - If true, shows this context menu; otherwise, hides this context menu.
 o isVisible
 public boolean isVisible()
Determines whether this context menu is visible.

Returns:
true if the context menu is visible; false otherwise.
 o show
 public void show(Component invoker,
                  int x,
                  int y)
Displays this context menu at the position x,y in the coordinate space of the specified invoker.

Parameters:
invoker - The component in whose space the context menu is to appear.
x - The x coordinate in the invoker's coordinate space at which the context menu is to be displayed.
y - The y coordinate in the invoker's coordinate space at which the context menu is to be displayed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index