SWT, Swing, or AWT - Which Is Right For You?
An anonymous reader writes "Why is there more than one Java GUI tool kit? The best answer is that one size does not fit all, nor is there a one-size-fits-all GUI tool kit to be invented soon. Each tool kit offers advantages and disadvantages that make selecting one more appropriate, given your needs and intended audience. Read descriptions of each tool kit's basic features, and the pros and cons of using each."
Just in case someone actually wants to read TFA:w ww.ibm.com/developerworks/opensource/library/os-sw ingswt/+awt+swing+swt+features+opensource+site:www .ibm.com&hl=en&gl=us&ct=clnk&cd=1&lr=lang_en
http://72.14.207.104/search?q=cache:Sdg9JPdYswMJ:
Since SWT is not available on Win64 it is Swing.
Pick something besides AWT/Swing, and your users need to download and install it. That lessens the chances that they pick your program, or that they will even be able to pick it - after all, every third-party library needed decreases the chances that all of them have been ported to the target platform.
Forget magic. Any technology distinguishable from divine power is insufficiently advanced.
That hardly answers the original question -- it's true, but it doesn't answer the statement in question. That would be like saying:
The reason why there are three toolkits is simply: originally, Sun developed AWT. AWT was introduced with Java 1.0 as a way to obsfucate the drawing of common GUI widgets on a variety of platforms, using the native widget set. Unfortunately, this was problematic for many platforms, and wasn't very flexible.
Thus, Sun developed Swing. It supported more widgets, and did a lot of its own drawing in order to appear and generally layout the same across different platforms.
Swing, unfortunately, has some design limitations, not the least of which is that it is very memory hungry. When IBM decided to "port" VisualAge for Java from being a Smalltalk-based product over to using Java, they found that Swing wasn't up to the task, so they decided to develop their own widget toolkit, called SWT. SWT wasn't exactly intended for use outside Eclipse, mind you -- it's just that many developers decided to use it as such.
So we're left with a bit of a GUI mess on our hands in the Java world -- one I really wish would be fixed. Swing works, but it can be slow and memory intensive. SWT is non-standard, and requires a platform-specific module which users may not already have installed (which means either you have to tell them to download and install it, or you have to create a bunch of installers for different platforms to allow them to run your SWT-based application).
That is why we have thre different toolkits. For all intents and purposes, the bulk of AWT is deprecated and shouldn't be used for its widgets. It is simply difficult to get rid of due to the number of legacy applications out there which are still using it, and which will probably never be updated to use Swing.
And then there is Cocoa-Java...
Yaz.
.... let me post two opposing sides of the swing vs swt debate:
Swt is crap
and
Swing is crap
Java programmer here. There is a Free project called Mono which is implementing most of .NET, even the non-standard WinForms is also emulated and they are offering alternatives with other GUI toolkits like Gtk#. Mono targets many platforms. Again, I'm a Java programmer and even I know this. I think diversity's good. Competition's good. What do you think the main driver is behind JSF? Yep, .NET's WebForms.
why run from Vincenzo?
I'm sorry, I can't see your circular reasoning.
/. and your relatively low UID.
Perhaps you meant "raises the question".
http://en.wikipedia.org/wiki/Begging_the_question
Surprising considering how often people get pulled up for this one on
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
Try netbeans 5, they have Mantisse, a GUI builder that handles layout managers in a straight-forward way. I didn't really believe the hype about it first, but a friend of mine very new to Swing managed to build a non-trivial UI that scales very well upon resize using nothing but it.
You can use Java with GTK, Cocoa, or native Windows toolkits. The question then becomes, why Java programmers are not interested.
The basic reason for this is, your application's GUI becomes completely unportable, and you suddenly have little reason for having written it in Java in the first place instead of the platform's "standard" language (C, Objective C, or C#).
A "middle way" is to do what SWT does and wrap the native widgets with a generic API. This creates a "lowest common denominator" problem, however, since you inevitably have to stick to only using those widgets which all your target platforms have...
Yeah, Mono is a nice project. Theres is also a Java .NET framework that can be used with it (IKVM).
As the article mentioned, Swing is a very good, advanced toolkit with some advantages over SWT. A project called SwingWT is an implementation of Swing using SWT, giving you a much faster GUI that looks and feels more native. So you can do all your development and initial testing with pure Swing, then swich the UI classes to SwingWT for a native look and feel on the hosts that support SWT. Seems like an interesting idea to me.
This may be a dumb question, but why can't Java just provide access to the existing desktop GUI (Windows, OSX, QT, whatever) rather than re-inventing the wheel with it's own set of widgets that inevitably don't look or behave like native apps?
It's not a stupid question.
Short answer: Because Java is meant to be cross-platform.
Long answer: I really don't want to re-write the ENTIRE GUI for each platform I port my app to. Would you? You're right, though - Java apps don't look like native apps. But that's a small thing to sacrifice for my app being able to run on almost any platform. However, they don't "behave" like native apps? Menu behavior is standardized. Buttons are standardized. They may not look the same, but they behave the same
Basically, you're using "re-inventing the wheel" is the wrong sense of the phrase, when it comes to programming. Sun can re-invent the wheel one time for each platform the JVM is ported to, or it can force you to re-invent the wheel for your GUI for *every* platform you want your app to run on. Pick one.
button.addEventLink(CommandEvent.class, this, "buttonPressed");
and every Java programmer should understand JavaBeans code likebutton.addActionListener(((ActionListener.class) EventHandler.create(ActionListener.class, this, "buttonPressed"));
Let's assume that I'm not to lazy to write a helper function to get rid of the casts in the JavaBeans version. Why would I want to use the Buoy event classes? Should I mix Buoy and EventHandler code when I want to use the more powerful EventHandler.create() variants?AWT is totally crap; it lacks much functionality of modern GUIs.
Swing is heavy; it implements its own window system, complete with event queues and region management. For those that don't know what regions are, they are display lists of visible rectangles. Clipping works by subtracting a region from another region, i.e. subtracting one list of rectangles from another list of rectangles. This means two things: a) crazy memory requirements, as each operation produces a new rect, b) slowness in order to compare all rectangles with each other.
SWT seems the better option, but I have no idea, even after reading the article, if it is totally portable and extensible from Java.