wood burning stoves
The moose likes Swing / AWT / SWT and the fly likes Diferences between AWT and Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Diferences between AWT and Swing" Watch "Diferences between AWT and Swing" New topic

Diferences between AWT and Swing

Vasco Dion�sio

Joined: Dec 04, 2003
Posts: 22
Could anyone tell me what are the main diferences between AWT and Swing.
Why should I use Swing and not the AWT?
Is Swing and improved "version" of AWT?
Sorry 'bout the basic questions...
Sharon Zakhour

Joined: Apr 26, 2004
Posts: 10
This question has come up a couple of times. AWT was Sun's first cut
at a GUI package for Java. The AWT team then identified several issues
they wanted to address and a splinter group began work on Swing,
which was originally a separately downloadable package. I believe that
in release 1.2 Swing was officially added to the J2SE core. The Swing Connection article, Getting Started With Swing, explains some of the major improvemnts. Here is
a summary:
- pluggable look and feel
This is especially exciting with the introduction, in release 1.4.2,
of the GTK look and feel.
- accessibility support
This is especially important now that providing accessible applications
is a Federal law, at least here in the U.S.
- much more sophisticated component design
For example, Swing components double buffer, AWT components don't.
AWT doesn't have complex components like JTable.
Swing components have built-in drag and drop support.
This list could go on and on...
You might also find the article by one of AWT and Swing's principle
designers, Amy Fowler, interesting,
Mixing Heavy and Light Components. (By the way, we don't recommend mixing heavyweight
and lightweight components, but it's an interesting article, none the less.)
One complaint that has been leveled against Swing is that it's slow.
This has been a concern within Sun and a major push, as of release 1.4,
was to improve performance. Release 1.4 did have major performance
improvements and this continues to be an ongoing effort.
I hope that answers some of your questions. Kathy has worked at Sun
for over 10 years and may have more interesting perspectives than I, who
has worked at Sun for only 5 years.
Sharon Zakhour
Kathy Walrath

Joined: Apr 26, 2004
Posts: 13
Sharon answered well. The only thing I'd add is that I believe AWT components are fully accessible now. Still, Sun strongly recommends using Swing instead of AWT whenever possible. My guess is that accessibility was the last feature added to the AWT components. Swing components, on the other hand, are actively being improved and extended.

Kathy Walrath<br />author, <a href="http://java.sun.com/docs/books/tutorial/" target="_blank" rel="nofollow">The Java Tutorial</a><br />editor, <a href="http://javadesktop.org" target="_blank" rel="nofollow">javadesktop.org</a>
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312

Good Painting Code Is the Key to App Performance
By Amy Fowler
In a graphical system, a windowing toolkit is usually responsible for providing a framework to make it relatively painless for a graphical user interface (GUI) to render the right bits to the screen at the right time.
Both the AWT (abstract windowing toolkit) and Swing provide such a framework. But the APIs that implement it are not well understood by some developers -- a problem that has led to programs not performing as well as they could.
This article explains the AWT and Swing paint mechanisms in detail. Its purpose is to help developers write correct and efficient GUI painting code. While the article covers the general paint mechanism (where and when to render), it does not tell how to use Swing's graphics APIs to render a correct output. To learn how to render nice graphics, visit the Java 2D Web site.
The main topics covered in this article are:
Evolution of Paint System
Painting in the AWT
System-Triggered vs. App-Triggered Painting
The Paint Method
Painting & Lightweight Components
"Smart" Painting
AWT Painting Guidelines
Painting in Swing
Double Buffering Support
Additional Paint Properties
The Paint Methods
Paint Processing
The Repaint Manager
Swing Painting Guidelines

Reference website

Java Developer, Thailand
I agree. Here's the link: http://aspose.com/file-tools
subject: Diferences between AWT and Swing
It's not a secret anymore!