Package com.ms.ui |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class UIMenuItem extends UIMenuLauncher { // Constructors public UIMenuItem(String text); public UIMenuItem(Component comp); public UIMenuItem(String text, UIMenuList menu); public UIMenuItem(Component comp, UIMenuList menu); // Methods public int getRoleCode(); public Insets insets(); public boolean keyDown(Event e, int key); public void paint(Graphics g); }
A class that 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 an example of how to create UIMenuItem and UIMenuList objects, see the UIMenuLauncher overview.
public UIMenuItem(String text);Creates a menu item using the specified string for content; the menu item has no associated pop-up menu.
Parameter Description text The text to be displayed.
public UIMenuItem(Component comp);Creates a menu item using the specified component for content; the menu item has no associated pop-up menu.
Parameter Description comp The component to be displayed.
public UIMenuItem(String text, UIMenuList menu);Creates a menu item with the specified string and menu.
Parameter Description text The text to be displayed. menu The UIMenuList object containing the content of the associated pop-up menu.
public UIMenuItem(Component comp, UIMenuList menu);Creates a menu item with the specified component and menu.
Parameter Description comp The component to be displayed. menu The UIMenuList object containing the content of the associated pop-up menu.
public int getRoleCode();Retrieves the role of the menu item control.
Return Value:
Returns the ROLE_SYSTEM code that best describes the role of the menu item.
Remarks:
This method returns the ROLE_SYSTEM_MENUITEM code.
public Insets insets();Determines the menu item's insets, which indicate the size of its border.
Return Value:
Returns an Insets object containing the menu item's insets.
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.
Parameter Description 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. If the key being pressed is the RIGHT ARROW, the associated menu is launched. If the LEFT ARROW key is being pressed, the menu is cancelled.
public void paint(Graphics g);Draws the menu item.
Return Value:
No return value.
Parameter Description g The graphics context. Remarks:
If the menu item has an associated pop-up menu, a right arrow is added to the menu item to indicate a menu can be launched.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.