#

| Chapter 1 Abstract Window Toolkit Overview |

## 1.2 Peers

Java programs always have the look and feel of the platform they are running on. If you create your program on a UNIX platform and deliver it to Microsoft Windows users, your program will have Motif's look and feel while you're developing it, but users will see Microsoft Windows objects when they use it. Java accomplishes this through a peer architecture, shown in Figure 1.10.

#### Figure 1.10: Peer architecture

There are several layers of software between your Java program and the actual screen. Let's say you are working with a scrollbar. On your screen, you see the scrollbar that's native to the platform you're using. This system-dependent scrollbar is the "peer" of the Java `Scrollbar` object. The peer scrollbar deals with events like mouse clicks first, passing along whatever it deems necessary to the corresponding Java component. The peer interface defines the relationship between each Java component and its peer; it is what allows a generic component (like a `Scrollbar`) to work with scrollbars on different platforms.

Peers are described in Chapter 15, Toolkit and Peers. However, you rarely need to worry about them; interaction between a Java program and a peer takes place behind the scenes. On occasion, you need to make sure that a component's peer exists in order to find out about platform-specific sizes. This process usually involves the `addNotify()` method.

Components |  | Layouts