Why is it said that Swings is heavy-weight and AWT is light-weight in JAVA?
views:
367answers:
3I don't totally understand the question and I'm sure this is going to result in a flamewar but perhaps it is because AWT provides a "simpler" API, though it is a bit more primitive. Swing however, is arguably a very top-heavy, or heavy weight, if you like API. It has far richer support and many more classes than AWT.
AWT is said to be "Heavyweight" because basically each AWT component is a native platform component. AWT is implemented on top of the platform's native GUI toolkit. This also explains why AWT was pretty limited compared to Swing. It uses the least common denominator as far as what is implemented.
Swing, on the other hand, is implemented in Java for pretty much everything except for top level components (windows...). There can be native components and those are still termed "heavy weight".
Take a look at this page from IBM for an in-depth comparison of AWT, Swing and SWT.
EDIT: I assume that was your question, even though heavy/light seem to be reversed in your phrasing. Heavy/light weight is pretty much a standard denomination in the Java GUI toolkits so I went with my understanding. (thanks to BobbyShaftoe for pointing that out).
In the Java world, AWT components are considered "heavy-weight" because they use underlying native components. When you instantiate an instance of java.awt.Button, you are actually asking the underlying OS to paint this object for you.
Swing, on the other hand, is "light-weight" because it mostly depends on the Java2D API to do all painting, which in turn delegates to the underlying OS or hardware. This also explains why Swing needs all those UI components that do the actual painting to mimic a specific look and feel (Windows, GTK, Motif, etc.).
Hope this helps.