O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Components and Peers

Most developers do not have to deal directly with peers. However, a handful of Component methods will behave differently if they are invoked before a component's peer has been created—those methods are listed in Table 11-4.

Peers are created in a component's addNotify method. If it is necessary to invoke one of the methods listed in Table 11-4 before a component's peer has been created, you essentially have two choices. You can either invoke addNotify() directly, which may cause the component's peer to be created, or you can override addNotify() and, after invoking super.addNotify(), call the methods that depend upon the peer's existence. For example, consider the applet listed in Example 11-1, which invokes some of the methods ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required