File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes What is a Java Peer Object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is a Java Peer Object?" Watch "What is a Java Peer Object?" New topic

What is a Java Peer Object?

Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
What is a peer object?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Java visual components are just pictures on a GUI. They do not actually have any functionality as far as the operating system is concerned.
In the AWT when you create a button the JVM "hooks" your button up to what the operating system thinks of as a "REAL" button. That is the OS peer.
In the original AWT all of the components were "heavyweight" components, meaning that they were tightly associated with the underlying peer component. This caused the "look and feel" of the components to be highly influenced by what the operating system defined that component to look like. That means that a button in Windows had a different look and feel from a Motif button on a Unix machine.
When Swing came along there was a lot of effort put into having the Java Components actually DO the work and therefore be less dependant on their underlying peer component. These components are considered to be "light-weight" because they are not so strongly influenced by the OS. This allows the look and feel of Swing component to be more consistant from platform to platform.
It is NOT a good idea to mix lightweight and heavyweight components - because the heavyweight ones will often trash the lightweight ones.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Thank you for the very clear explanation.
I agree. Here's the link:
subject: What is a Java Peer Object?
It's not a secret anymore!