Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't extend AWT component?

 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Questions:
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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 ...
Regards,
Manfred.
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manfred,
Great explanation! to great wonder
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic