File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Heavy weight vs. Light weight component" Watch "Heavy weight vs. Light weight component" New topic

Heavy weight vs. Light weight component

Mike Birken

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
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="" target="_blank" rel="nofollow">Beginning Java 2 SDK 1.4 Edition</a>
Valentin Crettaz
Gold Digger

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 ]

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link:
subject: Heavy weight vs. Light weight component
It's not a secret anymore!