Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing an AWT

 
jignesh soni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what makes awt a heavy weight component and Swing , a light weight component ?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For AWT buttons (for example), Java asks the operating system to draw a button. So, for example, a Windows control is created. The AWT component then has to keep track of a pointer to this native Windows button, and remember to dispose of it at some point. Making all these calls to the OS is what's considered "heavyweight".

For Swing buttons, the button is drawn on the screen in Java code. There are no native controls, no remembering to dispose of anything -- hence they are independent, free, "lightweight."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic