This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is peer ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is peer ?" Watch "what is peer ?" New topic

what is peer ?


Joined: May 12, 2000
Posts: 7
Dear Friends,
I would like to know the exact meaning of the word peer.
what is special about a class which is termed as a peer class?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
the term "peer" or "peer class" comes into usage especially when talking of awt vs swing. the terminology would say that swing does not use the peer classes and hence it is better. peer classes IMO would refer to the operating system dependent classes.
hope that helps
Tom P
Ranch Hand

Joined: May 06, 2000
Posts: 88
The peer classes are the classes that hook into the native API set in order to draw AWT objects.

Joined: May 12, 2000
Posts: 7
Thankyou Rahul and Tom..I get it now!
Now if the awt has such operating system dependent classes with lot of native code attached(heavy weight)then we cannot claim that java is fully portable.
Suppose we use some heavy weight component then it is not possible to guarantee the same performance on different platforms ?
2) Does swing have no native code attached with it or there is less native code compared to AWT ?
Moreover how does swing obtain the same functionality without using native code. what is the IN THING ! that makes swing light weight ?
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
You should check out the Swing trail in the Java Tutorial. The tutorial is available on the Sun's website. Read first few sections of the Swing trail, especially the one named How Are Swing Components Different from AWT Components? which answers most of your questions.
If you still have doubts after reading the tutorial, then perhaps you can come back here and we can discuss.
Happy reading..

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Tom P
Ranch Hand

Joined: May 06, 2000
Posts: 88
You are correct in stating that the peer classes will be operating system dependent.
I'm not sure that you can make any meaningful statements about performance on one platform based on performance on another platform (whether you are using lightweight or heavyweight components). There are so many variables between platforms that peer classes are probably the least of the issues.
Although Swing uses mostly lightweight components there are some heavyweight componenents included (JFrame, for example).
[This message has been edited by Tom P (edited May 18, 2000).]
I agree. Here's the link:
subject: what is peer ?
jQuery in Action, 3rd edition