Package com.ms.ui |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class UIMenuButton extends UIMenuLauncher { // Constructors public UIMenuButton(String string, UIMenuList menu); public UIMenuButton(String string, int style, UIMenuList menu); public UIMenuButton(Component comp, UIMenuList menu); public UIMenuButton(Component comp, int style, UIMenuList menu); // Methods public void cancelled(); public boolean launch(); public Rectangle getPlacement(Dimension size); public boolean action(Event e, Object o); public boolean gotFocus(Event e, Object o); public boolean keyDown(Event e, int key); public boolean mouseDown(Event e, int x, int y); public boolean mouseUp(Event e, int x, int y); }
A class that implements a menu button control. Each UIMenuButton object uses a UIMenuList control for the content of the button's associated pop-up menu.
For an example of how to create UIMenuButton and UIMenuList objects, see the UIMenuLauncher overview.
public UIMenuButton(String string, UIMenuList menu);Creates a menu button control with the specified text and menu.
Parameter Description string The text to be displayed within the button. menu The UIMenuList object containing the content of the associated pop-up menu. Remarks:
By default, the button's style is RAISED and the text is hot-tracked. To create a button whose text is not hot-tracked, pass a UIText object instead of a String, as shown in the following example.
UIMenuButton m = new UIMenuButton(new UIText("No hot-tracking"), myMenu);For more information about hot-tracking, see the UIButton overview.
public UIMenuButton(String string, int style, UIMenuList menu);Creates a menu button control with the specified text, style, and menu.
Parameter Description string The text to be displayed within the button. style The style of the button. Specify UIPushButton.RAISED or 0 for a flat style. (Note that specifying UIButton.TOGGLE or UIButton.TRITOGGLE has no effect. You must manually set and clear the button's checked state.) menu The UIMenuList object containing the content of the associated pop-up menu. Remarks:
By default, the text is hot-tracked. If any undefined style bits are specified, an IllegalArgumentException is thrown. To create a button whose text is not hot-tracked, pass a UIText object instead of a String, as shown in the following example.
UIMenuButton m = new UIMenuButton(new UIText("No hot-tracking"), 0, myMenu);For more information about hot-tracking, see the UIButton overview.
public UIMenuButton(Component comp, UIMenuList menu);Creates a menu button control with the specified component and menu.
Parameter Description comp The component to be displayed within the button. menu The UIMenuList object containing the content of the associated pop-up menu. Remarks:
By default, the button's style is RAISED. Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component. For examples of how to construct buttons, see the UIButton overview.
public UIMenuButton(Component comp, int style, UIMenuList menu);Creates a menu button control with the specified component, style, and menu.
Parameter Description comp The component to be displayed within the button. style The style of the button. Specify UIPushButton.RAISED or 0 for a flat style. (Note that specifying UIButton.TOGGLE or UIButton.TRITOGGLE has no effect. You must manually set and clear the button's checked state.) menu The UIMenuList object containing the content of the associated pop-up menu. Remarks:
If any undefined style bits are specified, an IllegalArgumentException is thrown. Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component. For examples of how to construct buttons, see the UIButton overview.
public boolean action(Event e, Object o);Reacts to the menu button being clicked by ignoring, launching, or cancelling 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 button. o The object that posted the event.
public void cancelled();Called by the button's associated pop-up menu when the menu is cancelled.
Return Value:
No return value.
public Rectangle getPlacement(Dimension size);Called by the button's associated pop-up menu when the menu is to be positioned.
Return Value:
Returns the bounding rectangle (in screen coordinates) of the pop-up menu.
Parameter Description size A Dimension object containing the preferred size of the pop-up menu. Remarks:
This method calls fitToScreen (inherited through UIMenuLauncher). By default, the pop-up menu is positioned below the button when it is launched.
public boolean gotFocus(Event e, Object o);Reacts to the menu button receiving focus.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter Description e The event posted to the button. o The object that posted the event (always null).
public boolean keyDown(Event e, int key);Determines whether the DOWN ARROW key is being pressed and, if so, launches the associated menu.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter Description e The event posted to the button. key The key that has been pressed.
public boolean launch();Launches the button's associated pop-up menu.
Return Value:
Returns true if the pop-up menu was launched; otherwise, returns false.
public boolean mouseDown(Event e, int x, int y);Reacts to the mouse button being pressed inside the button area by launching 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 button. x The x coordinate of the event. y The y coordinate of the event.
public boolean mouseUp(Event e, int x, int y);Reacts to the mouse button being released in the button area.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter Description e The event posted to the button. x The x coordinate of the event. y The y coordinate of the event.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.