Sign in to follow this  

[java] Newbie questions - AWT vs Swing

This topic is 4244 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am new to java but am pretty good with c# so getting my first few java programs up and running weren't a problem. I am reading different articles on the web about awt vs swing ect and can't quite tell what is the standard practice for gui's and java 1.5 Opinions seem to change depending on the date of the article so i was hoping someone here could get me up to speed on what to learn. Basically, i want to be able to write a standard app with a main window, menus and the usual windows stuff. Should i learn awt or swing? Also, i am using netbeans and ws wondering if there was anything i should be aware of when using the gui maker thing :) Thanks

Share this post


Link to post
Share on other sites
Hi,

Swing is a set of LIGHTWEIGHT components, that is, components that are independent of native calls of the OS - which is not the case for AWT, who is a set of HEAVYWEIGHT components.

I'd advise you to learn swing without an editor, first. It is of utmost importance that you learn the basics of swing before attempting to "draw" components in a tool that generates code for you, because it will be a mess to work with that code without knowing the basics of swing workflow.

Son Of Cain

Share this post


Link to post
Share on other sites
Swing all the way. It's easier to use, it looks the same on every OP(thought it might look different on older versions of the JVM), it looks ten times better, and AWT had text displaying problems on every computer I used.

Share this post


Link to post
Share on other sites
AWT is supported but obsolete, only old apps use it. Swing has much more advanced features. AWT used to be faster many years ago, but now Swing is well optimized and it even has hardware acceleration.
Only AWT widgets are obsolete: Swing is layered (some would say bolted...) on top of the basic AWT mechanisms and semi-compatible with it, allowing ugly and buggy mixed GUIs.
This legacy causes some confusion and complication due to compatibility kludges (e.g. Graphics and Graphics2D, Component and JComponent) and superseded interfaces leaving lots of reasonable-looking but wrong and dangerous methods in the widget classes.

Currently, the only significant alternative to Swing is SWT from the Eclipse project; it uses native widgets like AWT, with the same portability problems and bonus installation complexities, it is acceptably fast, and it is much less sophisticated than Swing (i.e. easier to understand and simple, but primitive and limited for practical use).

Share this post


Link to post
Share on other sites
I'd suggest learning AWT first because it is the foundation for Swing. Several pre-existing applications use it so it's important to know how to work with it. It doesn't mean you need to build new projects with it. It will help you understand what the need for Swing is, and how the details differ.

Share this post


Link to post
Share on other sites
AWT is practically dead so I wouldnt bother with it, you could spend your time bettering your skills at Swing or MFC than AWT. However i'd highly recommend writing Swing code manually i.e. Do not use Netbeans built in editor. I find this way your code stays clean and you can easily employ object orientated methodology through programming components instead of dragging and dropping them onto a Jpanel etc. However each to their own, and anyway, Swing is very simple to use.

I would recommend Eclipse as an editor. It practically codes for you.

Good Luck

Ste

Share this post


Link to post
Share on other sites
Dead? HAHAHAHAHA! Considering all the pre-existing programs out there (10 years) to modify & upgrade from time to time, obviously a clear understanding of AWT is important. If you don't know how to use AWT, it is difficult to use Swing effectively. Don't worry, learning AWT is learning Swing - just add a J :) It's the same thing with C and C++ programming. Being a good programmer is knowing where one ends and where the other begins. Java has that same requirement on the job. Anyway, learn things from the bottom up is my advice. I recommend Swing in the long run, though. It's more portable and extends major functionality to the old AWT components.

Share this post


Link to post
Share on other sites
Ok dead was the wrong term. It wouldnt hurt to know AWT however I would start off with Swing. Its the most used and tbh if your familar with Swing your familiar with AWT.

Share this post


Link to post
Share on other sites

This topic is 4244 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this