java.awt
Class PopupMenu

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.MenuComponent sample code for java.awt.MenuComponent definition code for java.awt.MenuComponent 
      extended by java.awt.MenuItem sample code for java.awt.MenuItem definition code for java.awt.MenuItem 
          extended by java.awt.Menu sample code for java.awt.Menu definition code for java.awt.Menu 
              extended by java.awt.PopupMenu
All Implemented Interfaces:
MenuContainer sample code for java.awt.MenuContainer definition code for java.awt.MenuContainer , Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible

public class PopupMenu
extends Menu sample code for java.awt.Menu definition code for java.awt.Menu

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.

See Also:
Serialized Form

Nested Class Summary
protected  class PopupMenu.AccessibleAWTPopupMenu sample code for java.awt.PopupMenu.AccessibleAWTPopupMenu definition code for java.awt.PopupMenu.AccessibleAWTPopupMenu
          Inner class of PopupMenu used to provide default support for accessibility.
 
Nested classes/interfaces inherited from class java.awt.Menu sample code for java.awt.Menu definition code for java.awt.Menu
Menu.AccessibleAWTMenu sample code for java.awt.Menu.AccessibleAWTMenu definition code for java.awt.Menu.AccessibleAWTMenu
 
Nested classes/interfaces inherited from class java.awt.MenuItem sample code for java.awt.MenuItem definition code for java.awt.MenuItem
MenuItem.AccessibleAWTMenuItem sample code for java.awt.MenuItem.AccessibleAWTMenuItem definition code for java.awt.MenuItem.AccessibleAWTMenuItem
 
Nested classes/interfaces inherited from class java.awt.MenuComponent sample code for java.awt.MenuComponent definition code for java.awt.MenuComponent
MenuComponent.AccessibleAWTMenuComponent sample code for java.awt.MenuComponent.AccessibleAWTMenuComponent definition code for java.awt.MenuComponent.AccessibleAWTMenuComponent
 
Constructor Summary
PopupMenu sample code for java.awt.PopupMenu.PopupMenu() definition code for java.awt.PopupMenu.PopupMenu() ()
          Creates a new popup menu with an empty name.
PopupMenu sample code for java.awt.PopupMenu.PopupMenu(java.lang.String) definition code for java.awt.PopupMenu.PopupMenu(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  label)
          Creates a new popup menu with the specified name.
 
Method Summary
 void addNotify sample code for java.awt.PopupMenu.addNotify() definition code for java.awt.PopupMenu.addNotify() ()
          Creates the popup menu's peer.
 AccessibleContext sample code for javax.accessibility.AccessibleContext definition code for javax.accessibility.AccessibleContext getAccessibleContext sample code for java.awt.PopupMenu.getAccessibleContext() definition code for java.awt.PopupMenu.getAccessibleContext() ()
          Gets the AccessibleContext associated with this PopupMenu.
 void show sample code for java.awt.PopupMenu.show(java.awt.Component, int, int) definition code for java.awt.PopupMenu.show(java.awt.Component, int, int) (Component sample code for java.awt.Component definition code for java.awt.Component  origin, int x, int y)
          Shows the popup menu at the x, y position relative to an origin component.
 
Methods inherited from class java.awt.Menu sample code for java.awt.Menu definition code for java.awt.Menu
add sample code for java.awt.Menu.add(java.awt.MenuItem) definition code for java.awt.Menu.add(java.awt.MenuItem) , add sample code for java.awt.Menu.add(java.lang.String) definition code for java.awt.Menu.add(java.lang.String) , addSeparator sample code for java.awt.Menu.addSeparator() definition code for java.awt.Menu.addSeparator() , countItems sample code for java.awt.Menu.countItems() definition code for java.awt.Menu.countItems() , getItem sample code for java.awt.Menu.getItem(int) definition code for java.awt.Menu.getItem(int) , getItemCount sample code for java.awt.Menu.getItemCount() definition code for java.awt.Menu.getItemCount() , insert sample code for java.awt.Menu.insert(java.awt.MenuItem, int) definition code for java.awt.Menu.insert(java.awt.MenuItem, int) , insert sample code for java.awt.Menu.insert(java.lang.String, int) definition code for java.awt.Menu.insert(java.lang.String, int) , insertSeparator sample code for java.awt.Menu.insertSeparator(int) definition code for java.awt.Menu.insertSeparator(int) , isTearOff sample code for java.awt.Menu.isTearOff() definition code for java.awt.Menu.isTearOff() , paramString sample code for java.awt.Menu.paramString() definition code for java.awt.Menu.paramString() , remove sample code for java.awt.Menu.remove(int) definition code for java.awt.Menu.remove(int) , remove sample code for java.awt.Menu.remove(java.awt.MenuComponent) definition code for java.awt.Menu.remove(java.awt.MenuComponent) , removeAll sample code for java.awt.Menu.removeAll() definition code for java.awt.Menu.removeAll() , removeNotify sample code for java.awt.Menu.removeNotify() definition code for java.awt.Menu.removeNotify()
 
Methods inherited from class java.awt.MenuItem sample code for java.awt.MenuItem definition code for java.awt.MenuItem
addActionListener sample code for java.awt.MenuItem.addActionListener(java.awt.event.ActionListener) definition code for java.awt.MenuItem.addActionListener(java.awt.event.ActionListener) , deleteShortcut sample code for java.awt.MenuItem.deleteShortcut() definition code for java.awt.MenuItem.deleteShortcut() , disable sample code for java.awt.MenuItem.disable() definition code for java.awt.MenuItem.disable() , disableEvents sample code for java.awt.MenuItem.disableEvents(long) definition code for java.awt.MenuItem.disableEvents(long) , enable sample code for java.awt.MenuItem.enable() definition code for java.awt.MenuItem.enable() , enable sample code for java.awt.MenuItem.enable(boolean) definition code for java.awt.MenuItem.enable(boolean) , enableEvents sample code for java.awt.MenuItem.enableEvents(long) definition code for java.awt.MenuItem.enableEvents(long) , getActionCommand sample code for java.awt.MenuItem.getActionCommand() definition code for java.awt.MenuItem.getActionCommand() , getActionListeners sample code for java.awt.MenuItem.getActionListeners() definition code for java.awt.MenuItem.getActionListeners() , getLabel sample code for java.awt.MenuItem.getLabel() definition code for java.awt.MenuItem.getLabel() , getListeners sample code for java.awt.MenuItem.getListeners(java.lang.Class) definition code for java.awt.MenuItem.getListeners(java.lang.Class) , getShortcut sample code for java.awt.MenuItem.getShortcut() definition code for java.awt.MenuItem.getShortcut() , isEnabled sample code for java.awt.MenuItem.isEnabled() definition code for java.awt.MenuItem.isEnabled() , processActionEvent sample code for java.awt.MenuItem.processActionEvent(java.awt.event.ActionEvent) definition code for java.awt.MenuItem.processActionEvent(java.awt.event.ActionEvent) , processEvent sample code for java.awt.MenuItem.processEvent(java.awt.AWTEvent) definition code for java.awt.MenuItem.processEvent(java.awt.AWTEvent) , removeActionListener sample code for java.awt.MenuItem.removeActionListener(java.awt.event.ActionListener) definition code for java.awt.MenuItem.removeActionListener(java.awt.event.ActionListener) , setActionCommand sample code for java.awt.MenuItem.setActionCommand(java.lang.String) definition code for java.awt.MenuItem.setActionCommand(java.lang.String) , setEnabled sample code for java.awt.MenuItem.setEnabled(boolean) definition code for java.awt.MenuItem.setEnabled(boolean) , setLabel sample code for java.awt.MenuItem.setLabel(java.lang.String) definition code for java.awt.MenuItem.setLabel(java.lang.String) , setShortcut sample code for java.awt.MenuItem.setShortcut(java.awt.MenuShortcut) definition code for java.awt.MenuItem.setShortcut(java.awt.MenuShortcut)
 
Methods inherited from class java.awt.MenuComponent sample code for java.awt.MenuComponent definition code for java.awt.MenuComponent
dispatchEvent sample code for java.awt.MenuComponent.dispatchEvent(java.awt.AWTEvent) definition code for java.awt.MenuComponent.dispatchEvent(java.awt.AWTEvent) , getFont sample code for java.awt.MenuComponent.getFont() definition code for java.awt.MenuComponent.getFont() , getName sample code for java.awt.MenuComponent.getName() definition code for java.awt.MenuComponent.getName() , getParent sample code for java.awt.MenuComponent.getParent() definition code for java.awt.MenuComponent.getParent() , getPeer sample code for java.awt.MenuComponent.getPeer() definition code for java.awt.MenuComponent.getPeer() , getTreeLock sample code for java.awt.MenuComponent.getTreeLock() definition code for java.awt.MenuComponent.getTreeLock() , postEvent sample code for java.awt.MenuComponent.postEvent(java.awt.Event) definition code for java.awt.MenuComponent.postEvent(java.awt.Event) , setFont sample code for java.awt.MenuComponent.setFont(java.awt.Font) definition code for java.awt.MenuComponent.setFont(java.awt.Font) , setName sample code for java.awt.MenuComponent.setName(java.lang.String) definition code for java.awt.MenuComponent.setName(java.lang.String) , toString sample code for java.awt.MenuComponent.toString() definition code for java.awt.MenuComponent.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 
Methods inherited from interface java.awt.MenuContainer sample code for java.awt.MenuContainer definition code for java.awt.MenuContainer
getFont sample code for java.awt.MenuContainer.getFont() definition code for java.awt.MenuContainer.getFont() , postEvent sample code for java.awt.MenuContainer.postEvent(java.awt.Event) definition code for java.awt.MenuContainer.postEvent(java.awt.Event)
 

Constructor Detail

PopupMenu sample code for java.awt.PopupMenu() definition code for java.awt.PopupMenu()

public PopupMenu()
          throws HeadlessException sample code for java.awt.HeadlessException definition code for java.awt.HeadlessException 
Creates a new popup menu with an empty name.

Throws:
HeadlessException sample code for java.awt.HeadlessException definition code for java.awt.HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
See Also:
GraphicsEnvironment.isHeadless() sample code for java.awt.GraphicsEnvironment.isHeadless() definition code for java.awt.GraphicsEnvironment.isHeadless()

PopupMenu sample code for java.awt.PopupMenu(java.lang.String) definition code for java.awt.PopupMenu(java.lang.String)

public PopupMenu(String sample code for java.lang.String definition code for java.lang.String  label)
          throws HeadlessException sample code for java.awt.HeadlessException definition code for java.awt.HeadlessException 
Creates a new popup menu with the specified name.

Parameters:
label - a non-null string specifying the popup menu's label
Throws:
HeadlessException sample code for java.awt.HeadlessException definition code for java.awt.HeadlessException - if GraphicsEnvironment.isHeadless() returns true.
See Also:
GraphicsEnvironment.isHeadless() sample code for java.awt.GraphicsEnvironment.isHeadless() definition code for java.awt.GraphicsEnvironment.isHeadless()
Method Detail

addNotify sample code for java.awt.PopupMenu.addNotify() definition code for java.awt.PopupMenu.addNotify()

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.

Overrides:
addNotify sample code for java.awt.Menu.addNotify() definition code for java.awt.Menu.addNotify() in class Menu sample code for java.awt.Menu definition code for java.awt.Menu

show sample code for java.awt.PopupMenu.show(java.awt.Component, int, int) definition code for java.awt.PopupMenu.show(java.awt.Component, int, int)

public void show(Component sample code for java.awt.Component definition code for java.awt.Component  origin,
                 int x,
                 int y)
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.

Parameters:
origin - the component which defines the coordinate space
x - the x coordinate position to popup the menu
y - the y coordinate position to popup the menu
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the parent is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this PopupMenu has a non-Component parent
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the origin is not in the parent's heirarchy
RuntimeException sample code for java.lang.RuntimeException definition code for java.lang.RuntimeException - if the parent is not showing on screen

getAccessibleContext sample code for java.awt.PopupMenu.getAccessibleContext() definition code for java.awt.PopupMenu.getAccessibleContext()

public AccessibleContext sample code for javax.accessibility.AccessibleContext definition code for javax.accessibility.AccessibleContext  getAccessibleContext()
Gets the AccessibleContext associated with this PopupMenu.

Specified by:
getAccessibleContext sample code for javax.accessibility.Accessible.getAccessibleContext() definition code for javax.accessibility.Accessible.getAccessibleContext() in interface Accessible sample code for javax.accessibility.Accessible definition code for javax.accessibility.Accessible
Overrides:
getAccessibleContext sample code for java.awt.Menu.getAccessibleContext() definition code for java.awt.Menu.getAccessibleContext() in class Menu sample code for java.awt.Menu definition code for java.awt.Menu
Returns:
the AccessibleContext of this PopupMenu