Difference between AWT and Swing in Java
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 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 heavily 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 platform-independent components. 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:
||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.
||The components of Java AWT are heavy weighted.
||The components of Java Swing are light weighted.
||Java AWT has comparatively less functionality as compared to Swing.
||Java Swing has more functionality as compared to AWT.
||The execution time of AWT is more than Swing.
||The execution time of Swing is less than AWT.
||The components of Java AWT are platform dependent.
||The components of Java Swing are platform independent.
||MVC pattern is not supported by AWT.
||MVC pattern is supported by Swing.
||AWT provides comparatively less powerful components.
||Swing provides more powerful components.
||AWT components require java.awt package
||Swing components requires javax.swing package
||AWT is a thin layer of code on top of the operating system.
||Swing is much larger swing also has very much richer functionality.
||AWT stands for Abstract windows toolkit .
||Swing is also called as JFC(java Foundation classes). It is part of oracle’s JFC.
||Using AWT , you have to implement a lot of things yourself .
||Swing has them built in.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!