Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when Swing component is heavyweight and when lightweight?

 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 898
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic