Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

swing  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is ligth and heavy weigth component in swing.please give
example also
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aadarsh,

In java a component is called
Heavyweight Component :- are those components which have a native peer classes( for a particular platform )associated with it.
These component do not know how to draw themselves. whenever a heavyweight component is drawn/redrawn it sends a signal to it's peer class . and this peer class draws the component with native look and feel.
So the look and feel of these component are tightly bound with the platform.
All AWT components are heavyweight components.
Lightweight components :- These components know how to draw themselves. so no peer classes involved and hence they can have custom look and feel.
moreover since there is no communication with peer classes is involved so u can say that they are more efficient in this context.
except Jwindow/JFrame/JDialog/JApplet these four components all other swing components are light weight.
peer classes Every GUI component has it's corresponding
class in the OS on which it is running. e.g. Button class in java will have a corresponding peer button in windows/Mac/X-windows.
and heavy weight components use these peers to draw them selves.


and for why peer was used i think it may be just because sun ppl must have wanted to release java ( awt ) earlier and so they used the native component while later they came out with Swing in which components have their own drawing code.
that's all i know
looking forward for comments from ranchers around
regards
Deekasha
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!