File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes What are the benefits to using the SWING class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "What are the benefits to using the SWING class?" Watch "What are the benefits to using the SWING class?" New topic

What are the benefits to using the SWING class?

R Woody

Joined: May 01, 2001
Posts: 2
I am a C/C++ programmer that is just starting to delve into the Java world. I have heard that SWING makes buttons/tools look more 3-dimensional, but that's about it. (I'm not even sure if that is true or not.) I'm wondering what the benefits are to using SWING?
Ashwin Desai
Ranch Hand

Joined: Jul 17, 2000
Posts: 124
The main problem with AWT was that the component look and feel and behavior was dependent on the OS platform where the VM executed. Thus, this is a violation of the platform neutrality that Java promises.
Swing is a set of "lightweight" components. I.e. there is lesser dependency on the native platform windowing toolkit. Also, Swing allows you to do things that were not even "thinkable" with AWT like
Pluggable look and feel,
borders around components,
images on buttons, lists.
tables, textpanes, progress bars etc.
For more information , refer
[This message has been edited by Ashwin Desai (edited May 01, 2001).]
wei Qiao

Joined: Jun 19, 2000
Posts: 23
Both AWT and Swing has their pro and cons. In general, AWT components are appropriate for simple applet development or development that targets a specific platform (i.e. the Java program will run on only one platform).
For most any other Java GUI development you will want to use Swing components.
Please looks at the following comparisions:
AWT: Pros
Speed: use of native peers speeds component performance.
Applet Portability: most Web browsers support AWT classes so AWT applets can run without the Java plugin.
Look and Feel: AWT components more closely reflect the look and feel of the OS they run on.
Portability: use of native peers creates platform specific limitations. Some components may not function at all on some platforms.
Third Party Development: the majority of component makers, including Borland and Sun, base new component development on Swing components. There is a much smaller set of AWT components available, thus placing the burden on the programmer to create his or her own AWT-based components.
Features: AWT components do not support features like icons and tool-tips.

Swing: Pros
Portability: Pure Java design provides for fewer platform specific limitations.
Behavior: Pure Java design allows for a greater range of behavior for Swing components since they are not limited by the native peers that AWT uses.
Features: Swing supports a wider range of features like icons and pop-up tool-tips for components.
Vendor Support: Swing development is more active. Sun puts much more energy into making Swing robust.
Look and Feel: The pluggable look and feel lets you design a single set of GUI components that can automatically have the look and feel of any OS platform (Microsoft Windows, Solaris, Macintosh, etc.). It also makes it easier to make global changes to your Java programs that provide greater accessibility (like picking a hi-contrast color scheme or changing all the fonts in all dialogs, etc.).
Applet Portability: Most Web browsers do not include the Swing classes, so the Java plugin must be used.
Performance: Swing components are generally slower and buggier than AWT, due to both the fact that they are pure Java and to video issues on various platforms. Since Swing components handle their own painting (rather than using native API's like DirectX on Windows) you may run into graphical glitches.
Look and Feel: Even when Swing components are set to use the look and feel of the OS they are run on, they may not look like their native counterparts.


Wei Qiao
R Woody

Joined: May 01, 2001
Posts: 2
Thanks! That was exactly the type of information I was looking for. VERY helpful!
R Woody
I agree. Here's the link:
subject: What are the benefits to using the SWING class?
It's not a secret anymore!