[2310] in java-interest
Re: peer classes?
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Fri Sep 29 07:41:14 1995
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: daemon@java.Eng.Sun.COM (Laura Lemay, Killer of Trees)
Date: Wed, 27 Sep 1995 19:29:54 -0800 (PDT)
Cc: java-interest@webrunner.neato.org (java)
In-Reply-To: <v02120d04ac8fa6dfd325@[140.174.94.4]> from "Laura Lemay, Killer of Trees" at Sep 27, 95 06:54:30 pm
Hi Laura,
> The beta JDK comes with a package called java.awt.peer, which contains
> Interface classes that parallel the classes in java.awt.
>
> Poking around in those classes, and in the source for AWT itself,
> I'm seeing references that mention that the peers are used to
> "modify the appearance of an object without changing its functionality."
>
> I'm afraid I don't understand what that means. Could someone explain
> that in a little more detail? Why are the peers needed? Isn't it
> possible to change an object's appearance without changing its
> functionality?
The peer classes are needed so that you can subclass AWT components and
we can slide in a different implementation depending on the native GUI toolkit.
The appearance changes but the functionality hopefully doesn't. Imagine if
you had to subclass MotifButton, that would mean that you are tied to one
toolkit. So the AWT lets you subclass Button, which in turn creates a "peer"
object called MotifButtonPeer. You never have to worry about peer objects
though, they are an implementation tool.
Have fun,
Arthur van Hoff (avh@eng.sun.com)
http://java.sun.com/people/avh/
Sun Microsystems Inc, M/S UPAL02-301,
100 Hamilton Avenue, Palo Alto CA 94301, USA
Tel: +1 415 473 7242, Fax: +1 415 473 7104
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com