Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Awt VS Swing

 
Steve De Costa
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference between AWT and Swing toolboxes.

I am trying to make a user interface for my program that displays some graphs.

Which one would you gus recommend I use? (and why?)
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing's are light weight component but,AWT is heavy weighted one.

To be more appropriate

Swing is pure java(i.e.,) what ever you create using swing Component will get created by java only and it is independent of Operating System(OS).On the other hand AWT uses native method to create Components for your application which makes it dependent on OS.

In case of performance,AWT wins over Swing.Because, the fact that swing is pure java which make a additional burden for the java to take care of swing components which surely affects java application performance for a bit.While,AWT Components are native methods which makes it less burden over Swing.

I recommend you not to mix both the AWT and Swing Component in your code.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing, not Swings.

Most people would use Swing because it allows you to specify a "look-and-feel." AWT components take the same look-and-feel as the operating system. For a user interface the slowest component of the process is the hand-to-mouse or hand-to-keyboard motion!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15367
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AWT is the old GUI toolkit that came with Java versions 1.0 and 1.1 (a long time ago). In Java 1.2, Swing was added.

For new software, use Swing, not just AWT.

See the tutorial: Creating a GUI with JFC/Swing
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AWT often looks more bland, but more important, it lacks native (i.e. Sun provided) support for more advanced controls such as tables and trees.
On the other hand, (nearly) every AWT control has a matching class in Swing, often using the same name but with a "J" in front of it. One notable exception is Choice vs JComboBox.
 
Steve De Costa
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is is true though that applets can only be made with awt and not SWING?

or applets can be made through SWIng as well.

Can anyone please send me a some small and good tutorial for Swing. I looked at the tutorial from sun at SUN's Swing Tutorial and they mostly tell us how to add gui using net beans. Not too much code especially for listeners..



Appreciate your help.

Thanks.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Steve De Costa:
Is is true though that applets can only be made with awt and not SWING?

or applets can be made through SWIng as well.

Here's a hint: JApplet
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the TOC for the Swing Trail where you saw the Netbeans stuff. Clearly you just didn't take time to look through it. There is only one small section on using Netbeans.
 
Steve De Costa
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob Prime. That clears out the doubt.

Gregg Bolinger, I couldn't get to that part, though I did look quite long enough everywhere on the net for a good SWING Tutorial.

Thanks everyone for your help.

Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic