Is Swing faster or AWT?

Swing is a light weight component while AWT is heavy weight. In this case Swing should be faster than AWT. But AWT has native component while Swing has to draw the components by itself. In this case, AWT should be faster than Swing. This confused me. Which one is faster?
[278 byte] By [youhaodiyia] at [2007-11-27 8:48:28]
# 1
The terms "lightweight" and "heavyweight" have nothing to do with speed. Therefore your first statement is meaningless. The second second statement is more accurate, but does it really matter. Whats a few milliseconds here and there?
camickra at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 2

If you really need to know, then create some sample applications yourself using awt and swing components separately (do not mix them) and run some tests. That would help clarify things for yourself.

However, to a great extent, you may never need to use AWT when developing your applications so you should just stick to Swing cause you can really control you components on that level. And with the improvements in the new JRE releases, speed is gradually not becoming issue, no matter which package you use. My advice stick to swing.

Besides, it depends on how you code your applications to will affect the speed of the app and the user perception of the application speed. With the help of Threads, ProgressBars, Splash Screens and other nifty UI tweaks, what ever percieved speed issues that exist with the program can be greatly minimized.

ICE

icewalker2ga at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 3
Does that mean AWT is obsoleted?
youhaodiyia at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 4

> Does that mean AWT is obsoleted?

To some extent yes. But does still have its uses, however, the usefulness of Swing far out ways those AWT provides. For example, Swing has the ability to easily add various kinds Borders to components, which cant be done as easily using AWT.

You can also customise the appearance and functionality of each component and with very little lines of code, you could have your Buttons, Lists Or Tables resembling those used in lastest operating systems. Swing is very versitile and I think you should stick to that, unless you have some exams to write on AWT, then you'd have to learn how that works as well.

ICE

icewalker2ga at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 5
Is there any condition AWT can do while Swing can't ?
youhaodiyia at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 6

> Is there any condition AWT can do while Swing can't ?

Maybe there is maybe there isn't.

You are still missing the whole point about Swing. Swing components are completely written in Java. If a Swing component doesn't do something that you want it to, then you can write custom code.

Not all functionality is built directly into Swing components. For example when using AWT text components, then you automatically have support for a popup menu with "copy", "cut" and "paste" functions when you right click on the text component. Swing components don't support this directly, but you can easily add this functionality if it is required.

camickra at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 7

AWT will be more useful if you are writing java application for handheld device such as PDA, barcode scanner. Special JVM required and mostly don't support Swing, for example IBM J9.

The speed issue will be clearer if you run your application on limited resources device (CLDC). Swing is the common "performance killer" for these devices. AWT or SWT is more popular, in fact, the popular Ecplise IDE is built on SWT. Anyway, Swing is built on top of AWT.

money_0422a at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...
# 8
> The speed issue will be clearer if you run your> application on limited resources device (CLDC). Swing> is the common "performance killer" for these devices.Why Swing is the common performance killer? Can you explain more on this?
youhaodiyia at 2007-7-12 20:55:33 > top of Java-index,Desktop,Core GUI APIs...