Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
263 Members
Join this group to post and comment.
AdhikariHarika Reshma
AdhikariHarika Reshma
Computer Science
02 Feb 2019

Difference between AWT and Swing in java

AWT and Swing both are used to create GUI interface in java.Both of them are used to perform almost same work,still they differ from each other.

1.AWT: It  stands for Abstract Window Toolkit.

Swing:It  is a part of Java Foundation Classes(JFC).

2.AWT: These components are heavy weight.

Swing:Swing components are called lightweight components because swing components sits on the top of AWT components and do the work.

3.AWT:AWT components are platform dependent so their look and feel changes according to OS.

Swing:Swing components are platform independent so their look and feel remains constant.

4.AWT:The components of this doesn't have very good look and feel as compared to swing components.

Swing:These components are better in look and feel as compared to AWT.

5.AWT: These components require java.awt.package.

Swing:It require javax.swing.package.

6.AWT:Using AWT one can implement a lot of things themselves.

Swing:swing has them built in

7.AWT:It is a thin layer of code on top of the OS.

Swing:Swing is much larger.It also has very much richer functionality.

8.AWT:With set we have 21peers(one for each control and one for the dialog itself).A peer is a widget provided by the OS such as button object or an entry filed object.

Swing:With swing we have only one peer the OS Window system.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.It has to draw the button or other control and implement its behaviour instead of relying on the host OS to perform those functions.