The AWT have classes (components) that provide a platform-independent API but that make use of platform-specific implementations (peers). Every AWT component object has a peer object that controls the object's look and feel.
Peers are created just before their corresponding component object is drawn for the first time.
Just before a container is shown for the first time, its peer -- and the peers of all components it contains -- is created.
If you add a component to a visible container, you need to explicitly tell the AWT to create a peer for the component. You do this by calling the validate() method.
Peers implement the feel (and, indirectly, the look) of UI components by reacting to user input events.
Peers are at the end of the event chain. After all the Components in the hierarchy have had an opportunity to handle the event, the peer gets to see and react to the event.
From raw events (key presses and mouse clicks) peers sometimes generate higher level events (actions, focus changes, ...). These higher level events are passed on to the relevant Component for handling.
![]() | Note |
---|---|
For mouse events, the peer is the first to see the event, and it doesn't necessarily pass all events on to the Component. |
Copyright © 1998-2009 Dilvan Moreira