public class java.awt
PopupMenu


Show All Login
Java SE 6
  
Extends: MenuComponent > MenuItem > Menu
Inner classes: PopupMenu.AccessibleAWTPopupMenu
Details
A class that implements a menu which can be dynamically popped up at a specified position within a component.

As the inheritance hierarchy implies, a PopupMenu can be used anywhere a Menu can be used. However, if you use a PopupMenu like a Menu (e.g., you add it to a MenuBar), then you cannot call show on that PopupMenu.
version1.34 04/07/06


Constructors
public PopupMenu() throws HeadlessException Details
Creates a new popup menu with an empty name.
ThrowsHeadlessException: if GraphicsEnvironment.isHeadless() returns true.
See also isHeadless
public PopupMenu(String label) throws HeadlessException Details
Creates a new popup menu with the specified name.
labela non-null string specifying the popup menu's label
ThrowsHeadlessException: if GraphicsEnvironment.isHeadless() returns true.
See also isHeadless

Methods
public void addNotify()
Creates the popup menu's peer. The peer allows us to change the appearance of the popup menu without changing any of the popup menu's functionality.
public void show(Component origin, int x, int y) Details
Shows the popup menu at the x, y position relative to an origin component. The origin component must be contained within the component hierarchy of the popup menu's parent. Both the origin and the parent must be showing on the screen for this method to be valid.

If this PopupMenu is being used as a Menu (i.e., it has a non-Component parent), then you cannot call this method on the PopupMenu.
originthe component which defines the coordinate space
xthe x coordinate position to popup the menu
ythe y coordinate position to popup the menu
ThrowsNullPointerException: if the parent is null
ThrowsIllegalArgumentException: if this PopupMenu has a non-Component parent
ThrowsIllegalArgumentException: if the origin is not in the parent's heirarchy
ThrowsRuntimeException: if the parent is not showing on screen


Properties
public AccessibleContext getAccessibleContext() Details
Gets the AccessibleContext associated with this PopupMenu.
returnthe AccessibleContext of this PopupMenu
since1.3
public MenuContainer getParent()
Returns the parent container for this menu component.