Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why swing are lightweight while awt are heavyweight?  RSS feed

 
Loi San Choon
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone help me to solve this message as soon as possible?
Swing components are often referred to as lightweight while AWT components are correspondingly called heavyweight components.
In your opinion, why are they named 'lightweight', 'heavyweight'?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because each "heavyweight" component has a native peer, and "lightweight" components do not. Since AWT is heavyweight, each AWT Button has a corresponding MFC button on the windows platform, or Motif button on a Unix platform. Since Swing is lightweight, the graphics of the button is just drawn on top of the frame... there is no underlying MFC or Motif button. You can find more information on this topic in the article "Mixing heavy and light components" on Sun's website.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!