Example usage for java.awt Component add

List of usage examples for java.awt Component add

Introduction

In this page you can find the example usage for java.awt Component add.

Prototype

public void add(PopupMenu popup) 

Source Link

Document

Adds the specified popup menu to the component.

Usage

From source file:PopupDemo.java

void addPopup(Component c, String name) {
    PopupMenu pm = new PopupMenu();
    MenuItem mi = new MenuItem(name + "-1");
    mi.addActionListener(this);
    pm.add(mi);/*  w  w w .  j av  a 2 s .  c  om*/

    mi = new MenuItem(name + "-2");
    pm.add(mi);

    setHash(c, pm);
    c.add(pm);
    c.addMouseListener(this);
}