Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2004

Tip: Looking for answers? Try searching our database.

Swing design, components vs. containers

Thread view: 
Martin Koch Andersen - 14 Oct 2004 20:15 GMT
Hi,

Can anyone explain me (or guess on) the motivation for why the Swing
developers decided to let JComponent extend the AWT Container class and
not the AWT Component class?

I find it strange that Swing does not seperate containers from
components in the class hierarchy (ie. you can add buttons to buttons etc.).

Any comments on this issue would be appreciated.

Signature

Martin - http://925.dk
"Shoot for the moon, even if you miss, you'll land among the stars."

Chris Smith - 14 Oct 2004 21:31 GMT
> Can anyone explain me (or guess on) the motivation for why the Swing
> developers decided to let JComponent extend the AWT Container class and
> not the AWT Component class?
>
> I find it strange that Swing does not seperate containers from
> components in the class hierarchy (ie. you can add buttons to buttons etc.).

Apparently, the answer is just "why not?".  The original reason that
this separation was made was that native controls often can't be
arbitrarily nested.  Since Swing manages and draws its own controls,
that reasoning is gone.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Thomas Weidenfeller - 15 Oct 2004 08:06 GMT
> Hi,
>
> Can anyone explain me (or guess on) the motivation for why the Swing
> developers decided to let JComponent extend the AWT Container class and
> not the AWT Component class?

I can guess.

1) In AWT Container inherits from Component, so every Container is also
a component.

2) I assume one wants to have the same relation in Swing. So JContainer
should inherit from JComponent.

3) Also, you want JContainer to inherit from Container,

4) and JComponent to inherit from Component.

5) But, you don't have multiple inheritance.

If you try to bring these requirements in some logical order, you end up
with the one you see in Swing. Because JComponent inherits from
JContainer, the JComponent subclass JContainer has has Container as a
parent.

/Thomas
Babu Kalakrishnan - 15 Oct 2004 11:59 GMT
> If you try to bring these requirements in some logical order, you end up
> with the one you see in Swing. Because JComponent inherits from
> JContainer, the JComponent subclass JContainer has has Container as a
> parent.

JContainer ??? Which version of the J2SDK are you referring to ?

BK
Thomas Weidenfeller - 15 Oct 2004 13:01 GMT
> JContainer ??? Which version of the J2SDK are you referring to ?

Uuuupssss. An imaginary, which only exists in my brain.

(Note to self: Don't post to Usenet after a four hours fight with Word
and a 100+ page ill-behaving document).

/Thomas
VisionSet - 15 Oct 2004 21:51 GMT
> (Note to self: Don't post to Usenet after a four hours fight with Word
> and a 100+ page ill-behaving document).

Programmers brain and using MS Word is a very dangerous combination!!

Signature

Mike W
SCJP, SCJD
Self congratulation for a limited time only!



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.