13.2. The Component Class

All windows and GUI controls in the AWT inherit from the Component class. Below, we summarize the more common methods in the class.

public void add(PopupMenu menu)

public void remove(MenuComponent menu)

The add method associates a PopupMenu with the component. The menu won't pop up automatically; use show in the PopupMenu class to display the menu. The remove method removes the menu from the component.

public void addNotify()

public void removeNotify()

The addNotify method creates the “peer” (native window system object) associated with the component. If the component peer needs to exist before some action is performed, then call this method (or setVisible). For custom components, be sure to call super.addNotify to ensure ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.