What is the difference between AWT and Swing in java

What is the difference between AWT and Swing in java?

This is one of the favorite java swing interview question asked for UI developer. Before looking at difference between AWT and Swing lets see what is AWT and what is Swing

AWT (Abstract Window Toolkit)

AWT is original Java GUI toolkit and simple where there are limited GUI components, layout managers, and events. Some commonly used components such as Tables, Trees, Progress Bars, and others, are not supported in AWT.

Swing

Java Swing is a very well-engineered, flexible, powerful GUI tool kit. Swing is built on parts of AWT. Java Swing uses the AWT event model and support classes, like Colors, Images, and Graphics.

Now let see difference between AWT and Swing

Difference between AWT and Swing

1. The base difference which everybody knows is Swing is Lightweight and AWT is heavy weight. But often you will be asked what is Heavyweight mean – answer is simple AWT components use the native code for getting the view component which is dependent on Operating System, that’s why the look and feel changes from OS to OS.

To overcome the variation in behavior across different hosts, Swing minimized its dependence on host controls. So it is called as lightweight.
Swing uses the term heavyweight for peer-based components and lightweight for emulated components. In fact, Swing supports mixed heavy and light components in a single GUI, such as mixing AWT and Swing controls in the same JContainer.
Difference between AWT and Swing in java
2.AWT components are thread-safe but Swing components are not thread-safe so you need to be careful which thread is updating the GUI if you are using multithreading.

3. Another difference is in Swing there is a separation between view and controller. Swing uses UI delegate which makes it more robust.

4. In case of Swing you can have facility to create Programmable look and feel using Java Swing API.

5. Another key difference is the use of renderer and editors which makes it very useful in controlling the showing the data and editing data.

About the author pranav

has written 205 post in this blog.

Pranav is a Java Developer and his liking is into the computer networking, windows , linux and latest tech updates. Started this blog focusing on java, windows, linux and internet tutorials and tips.

         
        

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>