Java Swing

Swing is part of JFC (Java foundation Classes). JFC is collection of API used to create GUI based applications. JFC contains swing, Java 2D api and AWT.

AWT existed before JFC. AWT was heavily criticized because of it's dependency on host operating system for drawing GUI widget.

AWT(Abstract Window Toolkit)

AWT was added in first release of java for GUI development. AWT has number of classes for creating frame, button, radiobutton etc. AWT components considered heavy weight.

AWT - Heavy weight components AWT components are platform dependent. Every AWT component has a native object known as peer that's why AWT components are considered heavy weight.

Each GUI component that AWT provides has a peer object. Peer is a implementation of that component in native operating system. It means when programmer create an AWT component that component actually drawn by native environment not by AWT. Glue which allow AWT component and peer to work together, is known as peer interface.

AWT component's look and feel influenced by underlying operating system. That means that a button in Windows had a different look and feel from a Motif button on a Unix machine.


Swing was developed to provide a platform independent API for GUI development. Swing was not part of first release of java, it was added later in java. Unlike AWT, swing components are drawn by JAVA itself. That's why swing provide a platform independent look and feel for it's components.

Swing - Light weight components Swing doesn't depend on native OS for drawing of GUI components. Look and feel of swing components can be changed.

Swing components are considered light weight as compared to AWT. There is no peer object for swing components.

Swing v/s AWT


Swing components are light weight.

AWT components are heavy weight.

Swing components are drawn by java itself that's why it'splatform independent. AWT components are platform dependent.
Look and Feel of swing can be changed. There is no such feature in AWT.
All of the buttons, entry fields, etc. are drawn by the Swing package on the drawing surface provided by the window object. This is the reason that Swing has more code. AWT is a thin layer of code on top of OS.
Swing components are generally slower than AWT. Use of native peers speeds component performance.
Swing supports a wider range of features like icons and pop-up tool-tips for components. AWT components do not support features like icons and tool-tips.
Swing has many advanced features like JTabel, Jtabbed pane which is not available in AWT. These feature is not available in AWT.