Popup Menus
Incredible as it may seem, popup menus were nowhere to be found in the original AWT. As a result, many developers implemented their own popups, but since such popups were drawn entirely in Java code and not implemented by a peer, the native look-and-feel was lost. Fortunately, this deficiency was remedied in the 1.1 version of the AWT with the introduction of a peer-based popup menu.
Popup menus are extremely easy to use. In this section, we'll discuss creating popups, displaying them, and handling the events they generate.
Popups and Components
Popup menus must be attached to an AWT component. In fact, java.awt.Component has two methods for attaching and removing popup menus:
add(PopupMenu popup)
remove(MenuComponent popup)
Creating ...
Get Graphic Java™ 1.2, Volume I: AWT, Third 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.