File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes can't extend AWT component? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can Watch "can New topic

can't extend AWT component?

Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
David M.Geary Graphic Java 1.2. Vol.1 AWT. The Sun Microsystems Press, p.6 states:
"Lightweight components"
The AWT's components are all heavy-weight, meaning they have peers and are rendered in their own native (opaque) windows. As a result, they are expensive to use and are not amenable to being subclassed in order to modify default behaviour. Additionally, they must be rectangular and cannot have transparent backgrounds

Nevertheless I subclass java.awt.Frame by and run w/o problem:

So if I may subclass, then I may add my methods. Adding methods is adding/changing behavior, isn't it?
1)What is the sense of "not amenable to being subclassed"?
2)What is hindering to have transparent background?

[This message has been edited by G Vanin (edited November 16, 2001).]
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Amenable means that it won't act like you think it will. It doesn't mean that you can't subclass it, but if you try to subclass and change the default behavior (i.e., painting, iconification, hiding, opening, etc) the behavior will probably not work as you expect.
The OS will interact with the heavyweight component and it is very diffficult to change the OS functions using AWT. There is even some problems using Swing ...
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
Great explanation! to great wonder
I agree. Here's the link:
subject: can't extend AWT component?
It's not a secret anymore!