Java is one of the most in-demand programming languages for developing a variety of applications. The popularity of Java can be attributed to its versatility as it can be used to design customized applications that are light and fast and serve a variety of purposes ranging from web services to android applications. Java is fast, reliable and secure. There are multiple ways to develop GUI based applications in java, out of which the most popular ones are AWT and Swing.
Before getting into the differences, let us first understand what each of them actually is.
AWT stands for Abstract Window Toolkit. It is a platform-dependent API to develop GUI (Graphical User Interface) or window-based applications in Java. It was developed by Sun Microsystems In 1995. It is heavy-weight in use because it is generated by the system’s host operating system. It contains a large number of classes and methods, which are used for creating and managing GUI.
Swing is a lightweight Java graphical user interface (GUI) that is used to create various applications. Swing has components which are platform-independent. It enables the user to create buttons and scroll bars. Swing includes packages for creating desktop applications in Java. Swing components are written in Java language. It is a part of Java Foundation Classes(JFC).
Difference between AWT and Swing:
|1.||Java AWT is an API to develop GUI applications in Java||Swing is a part of Java Foundation Classes and is used to create various applications.|
|2.||The components of Java AWT are heavy weighted.||The components of Java Swing are light weighted.|
|3.||Java AWT has comparatively less functionality as compared to Swing.||Java Swing has more functionality as compared to AWT.|
|4.||The execution time of AWT is more than Swing.||The execution time of Swing is less than AWT.|
|5.||The components of Java AWT are platform dependent.||The components of Java Swing are platform independent.|
|6.||MVC pattern is not supported by AWT.||MVC pattern is supported by Swing.|
|7.||AWT provides comparatively less powerful components.||Swing provides more powerful components.|
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.