[1964] in java-interest

home help back first fref pref prev next nref lref last post

Re: AWT instance variables

daemon@ATHENA.MIT.EDU (Ed Grossman)
Wed Sep 20 17:00:08 1995

Date: Wed, 20 Sep 1995 13:20:35 -0500
To: java-interest@java.Eng.Sun.COM
From: egrossma@ncsa.uiuc.edu (Ed Grossman)
Cc: egrossma@ncsa.uiuc.edu

OK,

Here is a list of things that I, as a class designer, might want a subclass
of an AWT object to do, which cannot be done within the current framework
unless the new objects are part of the AWT package.

1) As a descendant of Component, set my parent directly.  In fact, even the
"add" method of the Container object would not work if it were not in the
same package as Component.

2) As a descendant of Menu, change the order of my Menu items, or choose to
add a new item anyplace but the end of the menu.

3) As a descendant of Container, sort my children in place.

4) As a descendant of FlowLayout, change my alignment.

I'm sure I could come up with more.  Note that these are all things an
object would want to do to itself, not things it would allow other objects
to do.  The way AWT is written, subclasses as a rule do not have any more
privileged access to their ancestors' instance variables (which could
really be thought of as their own instance variables) than any other class,
thus making AWT extremely difficult to extend.

I'd like to know if this state of affairs is going to continue in future
releases.

-- Ed Grossman



At 8:29 PM 9/19/95, Arthur van Hoff wrote:
>Hi Ed,
>
>> I'm interested in why the AWT developers, upon removing the public instance
>> variables, made access on most of them the default, ie private outside the
>> package.  I've just started to write a few subclasses, and have quickly
>> discovered that the ramifications of this decision seem to be that I cannot
>> get access to my superclass' instance variables unless I put my new class
>> in the same package.  In that case, however, I have access to pretty much
>> any instance variable in the entire AWT.  Could one of the developers give
>> some idea of how they expect these classes to be reused?
>
>All the require instance variables are accessible through accessor
>methods. We chose to do it this way because it makes it harder to
>'accidentally' screw up the state of AWT components. We obviously
>want people to use these classes, but you should not stick new classes
>in the awt package.
>
>Have fun,
>
>        Arthur van Hoff


-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post