Difference between AWT and Swing
10898 Since 25th November, 2003
Select and Copy the Code
There are no big architectural differences, the class hierarchy is almost the same. The reason is that
Swing is built upon AWT.
The most significant difference is how the components are drawn to the screen. AWT is so called
heavyweight components and have their own viewport which sends the output to the screen. Swing is
ligthweight components and does not write itself to the screen, but redirect it to the component it builds
on. Heavyweight components also have their own z-ordering. This is the reason why you can't combine
AWT and Swing in the same container. If you do, AWT will always be drawn on top of the Swing
You can combine AWT and Swing, just don't do it in the same container (e.g. panel, groupbox, etc.) and
don't put a heavyweight component inside a lightweight.
Another difference is that Swing is pure Java, and therefore platform independent. Swing looks
identically on all platforms, while AWT looks different on different platforms.