aspose file tools*
The moose likes Beginning Java and the fly likes Heavy weight vs. Light weight component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Heavy weight vs. Light weight component" Watch "Heavy weight vs. Light weight component" New topic
Author

Heavy weight vs. Light weight component

Mike Birken
Greenhorn

Joined: Dec 28, 2001
Posts: 20
What is the difference between a heavy weight Swing component and a light weight Swing component?
- Mike
Ivor Horton
Author
Ranch Hand

Joined: Mar 22, 2002
Posts: 67
A heavyweight component relies on native code for its visual representation so it is drawn by the underlying operating system. Heavyweight components are those defined in the java.awt package
A lightweight component does not rely on native code - it is implemented entirely in Java. This means that a lightweight componet is entirely portable.
One consequence of the difference between heavyweight and lightweight components is that mixing them in the same application can cause trouble because they are drawn in different ways. You should avoid mixing them.


Ivor Horton<br />Author of the Beginning Java Series including the new <a href="http://www.amazon.com/exec/obidos/ASIN/1861005695/ref=ase_electricporkchop" target="_blank" rel="nofollow">Beginning Java 2 SDK 1.4 Edition</a>
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
An excellent article about heavyweight and lightweight components:
Swing connection: Mixing heavy and light components
Java Tutorial's $.02

As a rule, programs should not use "heavyweight" AWT components alongside Swing components. Heavyweight components include all the ready-to-use AWT components, such as Menu and ScrollPane, and all components that inherit from the AWT Canvas and Panel classes. When Swing components (and all other "lightweight" components) overlap with heavyweight components, the heavyweight component is always painted on top.

[ March 28, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Heavy weight vs. Light weight component