tags:

views:

191

answers:

6

If I want to code an desktop application in Windows with Java, should I buy a book about Swing and just skip reading books/tutorials about AWT?

Or do I have to learn AWT before using Swing?

+12  A: 

Just go straight to Swing.

Ignore awt.

There is no benefit getting your head around awt, as Swing is essentially a replacement for it.

Finglas
Swing is more of a wrapper around AWT than a replacement, but your sentiment holds true.
Jason Nichols
and what book should i read. a lot of people are recommending a book called Java Swing by some named Robert. but it doesn´t seem to have been updated since 2001-2002.
weng
@Jason - pretty much what I meant. Any modern day Java book the GUI examples all use Swing.
Finglas
As for books on Swing, you could start by looking at http://stackoverflow.com/questions/tagged/swing+books
Jonik
Jason Nichols: Mostly Swing adds to AWT. It does replace the heavyweight components of AWT. AWT grew without changing API, so it has a whole bunch of different stuff within the single `java.awt` package.
Tom Hawtin - tackline
+2  A: 

If you're doing this for yourself (and not part of work), might I suggest trying out the Qt or Gtk Java ports?

I don't know much about the Gtk one, but the Qt one is called Qt Jambi, and it's development is currently community driven, LGPL licensed. I've used both Swing (in Java) and Qt (for C++ apps), but if I ever had to develop java desktop applications again, I'd definitely give Qt Jambi a look before I decided what to pursue.

As for the Swing vs AWT - Swing straight away I would say.

laura
Also consider SWT (http://www.eclipse.org/swt/) if looking at alternative toolkits. It's quite popular at least.
Jonik
A: 

Well, Swing is richer in terms of out-of-the-box components than AWT. I have used both, and i prefer Swing over AWT. Also, you do not need to learn AWT to learn Swing basics.Sun's Swing tutorial is a good source to start learning Swing framework.

dc7780
+1  A: 

There's really no point in learning AWT first. Swing replaces a lot of AWT's concepts and components, but integrates many others unchanged (such as layout managers). If you learn Swing, you'll learn those parts of AWT that still matter (and how they are used in Swing) pretty much automatically.

Sun's Swing tutorial is a pretty good starting point.

Michael Borgwardt
A: 

As other answers have already mentioned there is no need to learn AWT and you can get your GUI coding with Swing alone.

As you develop your GUI code invariably you will bump across some AWT class (for example java.awt.event.ActionEvent) and you can comfortably use it by reading its API documentation. However your application need may make you to use a layout manager like GridBagLayout(java.awt.GridBagLayout), in which case you may have to study the layout manager documentation bit more in detail. I found this book on AWT Java AWT Reference, which is available online freely, to be quite useful when I needed to dig a bit more in detail about layout managers.

sateesh
A: 
  1. There is no need to learn AWT before learning Swing.
  2. Net Beans is a good IDE to learn Swing.
Grayskull