Series: Subject: Topic:
Question: 563 of 577

What are the differences between AWT and Swing

Asked by: Interview Candidate | Asked on: Aug 29th, 2005
Showing Answers 1 - 27 of 27 Answers

Answered On : Jun 3rd, 2005

AWT - Heavy weight component. Every graphical units it will invoke native methods. SWING - Light weight component. It doesn't invoke native methods.  Regards, Samuel

Yes  2 Users have rated as useful.
Login to rate this answer.
lokesh mishra

Answered On : Jul 21st, 2005

Swing is based on MVC architetcure(Model view Controller) and thats why its look and feel is independent of hardware and OS...whereas AWT look and feel depends upon the platform...

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Jul 25th, 2005

Mr. Lokesh Mishra...let me correct you....swing came into existence long back when no body heard about MVC Architecture.   And for the answer of the question, I would like to add another point to Samuel's answer i.e  SWING is an extension of AWT.....having advance controls and with extra features of previously present controls 

Login to rate this answer.
anil sharma

Answered On : Jul 27th, 2005

Swing are the extension of Awt. Awt have some disadvanage that are removed by he swing .for example awt programs are not machine independent. it causes some problem on different machine whereas his does not occur in swing.  extension

Yes  2 Users have rated as useful.
Login to rate this answer.
satyendra chaudhary

Answered On : Jul 30th, 2005

Actually awt methods and classes r tied to the local machine on which the application or applet executes....thats why call heavy-weighted cause the appreance will change from plateform to plateform.....where as the swing is fully written in java and its capablities r not tried to local plateforf(lightweight)

Login to rate this answer.

Answered On : Aug 5th, 2005

AWT are Heavy Weight Components and Swings are Light Weight Components. But Swings are extension of AWTs only.

Login to rate this answer.
Sachin Dhanmane

Answered On : Aug 29th, 2005

Good answer

Login to rate this answer.
atul kabra

Answered On : Sep 12th, 2005

Swing components have different look and feel also swing uses the model view controller architecture. Swing compoent is a light weight component where as awt is heavy weight compoent. Swing provides some advanced compoent like JTree, JTabbedPane, JList and many more

Login to rate this answer.
Mohammed Farooq ali

Answered On : Sep 18th, 2005

AWT is heavy weight component whereas Swings is a light weight. Swings has pluggable look'n'feel architecture. AWT occupies more memory space unlike Swings which occupies less memory space.

Login to rate this answer.

Answered On : Sep 22nd, 2005

Hi to every body.AWT is platform dependent and SWING is platform independent. swing includes more graphic components then awt.Ritesh sharma

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Sep 28th, 2005

AWT is heavy weight components which take time for loading. Swing is light weight components which take more time for first time loading after then its uses allready loaded componets. so that swing is faster than awt components. -- jayant dhargawe

Login to rate this answer.

Answered On : Sep 29th, 2005

hi,the major defferense between awt and swings isawt is heavy weight component nothing but it is based on operating system.but the swings are light weight components,this is the independent of operating system.

Login to rate this answer.
Ajay Srivastav

Answered On : Oct 15th, 2005

Swing is light weight compnent then awt.& contain some extra component then awt

Login to rate this answer.
Devidas Sonawane

Answered On : Oct 21st, 2005

Awt is heavy weight component and swing is light weight components,  look and fill feature and also platform independance.

Login to rate this answer.

Answered On : Aug 3rd, 2006

In AWT, native "peer" code, written in a language like C or C++, It uses system callls display widgets. So it is not plateform independent and it heavy weight .Other side swings , native "peer" code is written in java itself which uses JRE which is specific to the plateform , so the code what we write is platefom independent and light weight .

Login to rate this answer.
shyam nair

Answered On : Sep 20th, 2006

Hi Guys,              The difference between swings and Awt components are       1. the base difference that which already everyone mentioned is that One is heavy weight and other is light weight. Let me explain, bacially what the term heavy weight means is that when you are using the awt components the native code used for getting the view component is generated by the Operating System, thats why it the look and feel changes from OS to OS. Where as in swing components its the responsibility of jvm to generate the view for the components. Another statement which i saw is that swing is MVC based and awt is not. First of all let me tell one thing MVC is not a programming technique, its only a pattern. In the sense it is a way of implementation, or in other words, a pattern is a non-recurring solution to a recurring problem. Its up to the programmer that whether you should follow the MVC or not with your components. If the programmer needs what i will say is that its he can implement the concept of MVC in both awt and swings. Thats all Thanks  

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Sep 21st, 2006

Swing is an extension of, and not a replacement for the AWT. There is some overlap between AWT and Swing (for example a Swing JButton component might

Login to rate this answer.
hitesh karel

Answered On : Nov 3rd, 2006

Everyone saying that AWT - Heavy weight and Swing - light Weight.But what is meaning here Weight here.

Login to rate this answer.
Hari krishnan.s

Answered On : Mar 27th, 2007

The main difference between Swing and Awt is that Awt components are peer components to the native widgets. In other words, when you allocate a Button, the java code uses a native component that the OS knows about for that button. All drawing and event handling happens at the OS level. (ie Windows or X Windows code is handling those two areas). AWT listens for events, and calls your hooks for you to interact with them. This implemenation is usually referred to as a heavyweight component. AWT components are heavyweight.Swing is pure Java. Most of the components that Swing uses are referred to as lightweight. Both drawing and events are handled by Java code. This makes applications much more portable, Primiarily, because heavyweight event notification is dependant on the OS' implementation. However, since drawing is done by Java code this places a lot of burden on performance of java. In 1.4 swing performance is a lot faster than in previous versions. (Actually, this will be more true in 1.4.1 as there is a bug that Sun is working on that degrades performance of all Java apps using 1.4). You can intermix the AWT and Swing. Heavyweight and lightweigh components in the same application, but there are some limitations to doing that. Swing is very flexible, and very nice to work with. (Some days ;-)Finally, another major difference is that AWT does not support fancy widgets like tables, trees, or formated text components. AWT was originally designed to be very simple. And, it is, but you don't get very useful widgets with it, IMHO. You could try using SWT by IBM which is like AWT in the fact that it too is heavy weight, and it provides more up to date pallette of widgets. It's not as nicely designed as Swing.

Login to rate this answer.

Answered On : Apr 11th, 2007

In AWT (Abstract Window Toolkit) there is no main method in the program. In Swing there is a main method in the program.Swing is an extension of AWT.There is a new concept called SWT (Standard Widget Toolkit). SWT is an extension of Swing.-Iftakhar.

Yes  1 User has rated as useful.
Login to rate this answer.

Answered On : Apr 11th, 2007

AWT - Heavy weight component. For every graphical unit it will allocate many resources and waste of resources. AWT does't have opearting platform window.SWING - Light weight component. it's has own operating platform window.It's has many features.

Login to rate this answer.
Mohan Seripalli

Answered On : Aug 30th, 2007

I would like to add one more difference.AWT components(Button, Label, etc.,) are multi-thread safe.Swing Components(JButton, JLabel ,etc., ) are not designed to be thread safe. The main reason is to gain performance. The java developer is responsible to handle any thread safety for swing components.

Login to rate this answer.

Swings are lightweight components,Double buffered,Supports tool tip properties,Swings are extension of AWT not a replacement for AWT.It does not interact with native code.AWT are heavyweight components,Intract with native code and doesnt supports tool tip properties.

Login to rate this answer.

Answered On : Apr 20th, 2010

View all answers by karthik221

AWT are heavy weight components while Swing are light weight components.  Light weight components have transparent pixels where as heavy weight is always opaque.  Light weight components are non-rectangular.  Heavy weight components are rectangular.

Login to rate this answer.

Answered On : Nov 28th, 2011

Dear Sir/madam

If AWT is platform dependent then how we can say that the Java is not platform dependent.
please explain me.

Thank you

Login to rate this answer.

Answered On : Jan 16th, 2012

View all answers by Nitilaksha


They are right !!!! since AWT is platform dependent which behaves differently in different platforms which defeats our Write Once and Run anywhere.The Java Native Interface (JNI) enabled developers to add platform-dependent functionality to Java applications.
Here in case of AWT we can use AWT Native Interface is which very similar to the JNI.

Login to rate this answer.

Answered On : Jan 20th, 2012

As far as I know Java itself acts a platform which will be used by AWT.

Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.