wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes when Swing component is heavyweight and when lightweight? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "when Swing component is heavyweight and when lightweight?" Watch "when Swing component is heavyweight and when lightweight?" New topic
Author

when Swing component is heavyweight and when lightweight?

Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
In http://java.sun.com/products/jfc/tsc/articles/mixing/index.html

A lightweight component is one that "borrows" the screen resource of an ancestor (which means it has no native resource of its own -- so it's "lighter").
and further
all Swing components are lightweight (except for the top-level ones: JWindow, JFrame, JDialog, and JApplet)

I did not quite get:


  • Is "ancestor" in first citation in the sense of inheritance or in the sense of containment hierarchy?

  • According to second citation it appears to me that top-level does not have sense of inheritance. Does it mean that any other Swing component will be heavyweigh as soon as an instance at the top of containment hierarchy? i.e. is not inside any other container


Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi G,
It has nothing to do with heirarchy. It refers to using the local OS for rendering or just using java to render a component. Top level components (JWindow, JFrame, JDialog, etc) use the OS to render them. This makes them HEAVY because the OS is large and must be present in order for the components to be rendered correctly.
Lightweight refers to rendering in Java which is much smaller and portable code. This also allows a component to look the same no matter what OS it is rendered in.
Regards,
Manfred.
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
Manfred,
it does not seem to me being more lightweight when you have heavyweight peers not directly but through ancestors.

the OS is large and must be present in order (/QUOTE)
Can you explain how and where it should be present (in class, thru a member)?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: when Swing component is heavyweight and when lightweight?
 
Similar Threads
Difference between lightweight and heavyweight objects
swing and Awt
Is JFrame added to JFrame heavyweight or lightweight?
Differnece between setVisible() and show() methods
Swing Vs AWT