Several consequences result from this difference between AWT and Swing. AWT
is a thin layer of code on top of the OS, whereas Swing is much larger.
Swing also has very much richer functionality. Using AWT, you have to
implement a lot of things yourself, while Swing has them built in. For
GUI-intensive work, AWT feels very primitive to work with compared to Swing.
Because Swing implements GUI functionality itself rather than relying on the
host OS, it can offer a richer environment on all platforms Java runs on.
AWT is more limited in supplying the same functionality on all platforms
because not all platforms implement the same-looking controls in the same
ways.
Swing components are called "lightweight" because they do not require a
native OS object to implement their functionality. JDialog and JFrame are
heavyweight, because they do have a peer. So components like JButton,
JTextArea, etc., are lightweight because they do not have an OS peer. A "peer" is a
widget provided by the operating system, such as a button object or an entry
field object.