This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Swing an AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Swing an AWT" Watch "Swing an AWT" New topic

Swing an AWT

jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
what makes awt a heavy weight component and Swing , a light weight component ?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

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."

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Swing an AWT
Similar Threads
Swing - Content Pane vs. Panel - have I got this right?
How to insert java code in Static HTML page ?
how to make Canvas transparent ?
lightweight component
why applet is heavy weight and swing is called light weight?