• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is a Java Peer Object?

 
Stanley Tan
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a peer object?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stanley Tan
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the very clear explanation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic