Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


Class UIMenuItem

public class UIMenuItem extends UIMenuLauncher
{
  // Constructors
  public UIMenuItem(String text);
  public UIMenuItem(String text, UIMenuList menu);
  public UIMenuItem(IUIComponent comp);
  public UIMenuItem(IUIComponent comp, UIMenuList menu);

  // Methods
  public boolean action(Event e, Object o);
  public Insets getInsets();
  public int getRoleCode();
  public boolean keyDown(Event e, int key);
  public void paint(FxGraphics g);
}

This class implements a menu item control. A UIMenuItem object can be used to launch a pop-up menu. Typically, you'll create a UIMenuButton control with an associated pop-up menu. This menu uses a UIMenuList object for content, which displays a list of items. From those items that are UIMenuItem objects, other pop-up menus can be launched.

For more information about using UIMenuItem objects, see the UIMenuLauncher overview.

UIComponent
  |
  +--UIContainer
    |
    +--UIStateContainer
      |
      +--UISingleContainer
        |
        +--UIMenuLauncher
          |
          +--UIMenuItem

Constructors

UIMenuItem

public UIMenuItem(String text);

Creates a menu item with the specified text. The menu item has no associated pop-up menu.

ParameterDescription
text The text to be displayed by the item.

UIMenuItem

public UIMenuItem(String text, UIMenuList menu);

Creates a menu item using the specified text and menu.

ParameterDescription
text The text to be displayed by the item.
menu The UIMenuList object containing the content of the associated pop-up menu.

UIMenuItem

public UIMenuItem(IUIComponent comp);

Creates a menu item with the specified component. The menu item has no associated pop-up menu.

ParameterDescription
comp The component to be displayed by the item.

Remarks:

Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component.

UIMenuItem

public UIMenuItem(IUIComponent comp, UIMenuList menu);

Creates a menu item with the specified component and menu.

ParameterDescription
comp The component to be displayed by the item.
menu The UIMenuList object containing the content of the associated pop-up menu.

Remarks:

Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component.

Methods

action

public boolean action(Event e, Object o);

Responds to an action that has occurred within the control.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
e The event posted to the control.
o The object that posted the event.

getInsets

public Insets getInsets();

Retrieves the menu item control's insets (in pixels), which identify the nonclient area of the control.

Return Value:

Returns an Insets object containing the menu item's insets.

getRoleCode

public int getRoleCode();

Retrieves the ROLE_SYSTEM code that best describes the role of the menu item control.

Return Value:

Returns the ROLE_SYSTEM_MENUITEM code.

keyDown

public boolean keyDown(Event e, int key);

Determines whether the RIGHT ARROW key or the LEFT ARROW key is being pressed, and if so, launches or cancels the associated pop-up menu.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
e The event posted to the menu item control.
key The key that has been pressed.

Remarks:

This method is called when the menu item has focus and a key is pressed. keyDown invokes launch if the RIGHT ARROW key is being pressed, or cancel if the LEFT ARROW key is being pressed. (These two methods are inherited from UIMenuLauncher.)

paint

public void paint(FxGraphics g);

Draws the menu item.

Return Value:

No return value.

ParameterDescription
g The graphics context.

Remarks:

If the menu item has an associated pop-up menu, the system-defined right arrow is added to the menu item to indicate a menu can be launched.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.