Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swing or AWT?

Status
Not open for further replies.

Huitzilopochtli

Programmer
Feb 18, 2002
81
DE
Hello

This is quite a simple question (I hope!).

Is it right to say that there are 2 ways of writing applets? One is using AWT and the other is using Swing? And the two have to be used separately? In other words you can't use this from AWT and that from Swing? Are there any advantages of using one over the other and which is likely to have a future?

My apologies for the naivete of the question, but when I visit Sun I am completely overwhelmed by acronyms and the sheer vastness of it all!

Best wishes
 
yes, you are right. AWT is the original Java method for creating GUI's - specifically for Applets, which is why alot of people still think that Java is purely a web based language.

Sun decided to launch java at thoe wishing to create business standard applications and needed a decent GUI library to achieve this to make it more appealing to those used to dealing with systems written in languages such as C++ and VB. And thus Swing was born.

You can still do all you could do in AWT with Swing but it is also perfect for building applications running outside of browsers.

When you write an applet you therefore have a choice of two methods, and really the only difference is in the naming (all Swing classes start with a 'J' - JApplet, JTextField etc) and swing still uses a lot of the original awt classes, the main difference has been in the controls available in swing which look like they have been created to compete with MFC native controls.

You cannot use AWT controls in a swing applet and vice versa, and really the main consideration is browser support. AWT being the original applet library, is supported across most (older) browsers, Swing being relatively new (although it is still a couple of years old now and came out with java 2) was not initially supported and it was usual to need to convert the html page containing the applet using software available from sun. Alot of the original AWT has been deprecated.

But really Swing has opened the door for widespread use in business applications and has taken Java away from being a mainly web based language.
 
Hello PIPK

Many thanks for your message.

You have clarified what I was beginning to think. I suppose a good grounding in AWT can't be replaced, but we need to have one eye on future Swing developments.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top