[Chapter 19] PopupMenu

#

| Chapter 19 java.awt Reference |

# PopupMenu

## Name

PopupMenu

##

## Description

A `PopupMenu` is a menu that can be popped up on a `Component`.

## Class Definition

    public class java.awt.PopupMenu
        extends java.awt.Menu {

      // Constructors
      public PopupMenu();
      public PopupMenu (String label);

      // Instance Methods
      public synchronized void addNotify();
      public void show (Component origin, int x, int y);
    }

## Constructors

### PopupMenu

#### public PopupMenu()

Description

  Constructs a PopupMenu object.

#### public PopupMenu (String label)

Parameters

  label

    Text that appears on `Menu`.

Description

  Constructs a PopupMenu object with the given label.

## Instance Methods

### addNotify

#### public synchronized void addNotify()

Overrides

  `Menu.addNotify()`

Description

  Creates a Popup`Menu` peer.

### show

#### public void show (Component origin, int x, int y)

Parameters

  origin

    The `Component` upon which the `PopupMenu` will be displayed.

  x

    The `PopupMenu`'s horizontal position on the component.

  y

    The `PopupMenu`'s vertical position on the component.

Description

  Shows the menu on the given `Component`. The origin specified must be contained in the hierarchy of the `PopupMenu`'s parent component, which is determined by the call to `Component.add(PopupMenu)`.

Polygon |  | PrintGraphics