This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes learning swing .... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "learning swing ...." Watch "learning swing ...." New topic
Author

learning swing ....

mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
i am starting out with swing. (awt was simple and fun to learn and easy too...)
there is a prefix 'J' for similar classes in awt. (looks though from the api heirarchy)
like Component (in awt) and JComponent (in swing) but then there is nothing as JContainer ?
can someone let me know some sort of similarities etc between swing and awt so that learning can be easy and logical too ?
(one difference was with how we add components in awt and swing, any other differences... )
and the class JColorChooser, wow what a class.... its a full fledged application ! any other such noteworthy classes !!!
Rajendar
Greenhorn

Joined: Feb 28, 2002
Posts: 9
Originally posted by mark stone:
i am starting out with swing. (awt was simple and fun to learn and easy too...)
there is a prefix 'J' for similar classes in awt. (looks though from the api heirarchy)
like Component (in awt) and JComponent (in swing) but then there is nothing as JContainer ?
can someone let me know some sort of similarities etc between swing and awt so that learning can be easy and logical too ?
(one difference was with how we add components in awt and swing, any other differences... )
and the class JColorChooser, wow what a class.... its a full fledged application ! any other such noteworthy classes !!!


Raj
Rajendar
Greenhorn

Joined: Feb 28, 2002
Posts: 9
mark,
yes swing is very powerful when compared to awt.
it got a lot more useful classes which makes life easy.
The eventhandling mechanism is the same as in Awt ,but u can achieve a lot than that in Awt.
classes like JTable,JTree which help u create tables and trees directly,which wasnt possible in AWT.
Like this there are a lot more useful classes.Learning swing is not difficult.
Hope this helps..

Originally posted by mark stone:
i am starting out with swing. (awt was simple and fun to learn and easy too...)
there is a prefix 'J' for similar classes in awt. (looks though from the api heirarchy)
like Component (in awt) and JComponent (in swing) but then there is nothing as JContainer ?
can someone let me know some sort of similarities etc between swing and awt so that learning can be easy and logical too ?
(one difference was with how we add components in awt and swing, any other differences... )
and the class JColorChooser, wow what a class.... its a full fledged application ! any other such noteworthy classes !!!
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
hi Mark. yes you are right Swing is much better than awt. the reasons for that is that awt uses the native system for its graphics and thus need to look for the lowest common thing in order to support all the platforms. swing is platform independant and all will look the same on all platform !
the main diffrences i can think of are:
1) like you said, all components in swing begin with a capital J .(notice that not the layout , only the components).
2) you dont add components to a JFrame directly, like you did with frame but you use its content pane to add things to it.
3) there is another layout called BoxLayout added to the regular use of layouts.
4) There is no longer an equivalent of Canvas. use JPanel instead.
5) Checkbox is now JCheckBox (notice the capital B).
6) to make radio Buttons you dont do it as you did in awt. you now have a class called JRadioButton and you add those radiobuttons to a class called ButtonGroup. (no J here too).
7) to set the menu in the JFrame use the method : setJMenuBar (not setMenuBar).
8) dont juse SWING components with AWT components cause it messes up the graphics.
9) there is JComboBox instead of Choice class.
10)you can use the function setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) so that it will close when u press the x (you dont have to write a listener to do that like in awt).
11) you have diffrent look and feels
12) You can use icons in buttons and labels with ImageIcon.
13) use can use HTML as text in buttons and labels.
14) You have borders you can add to components.
15) you have the JOptionPane to show simple dialogs and the JColorChooser and JFileChooser dialogs made for you.
16) you have ToolBar, Tooltip and ProgressBar you can use.
17) and many many more speacial panels like: splitpane,scrollpane,tabbedpabe,desktoppane etc..
here is a good link to sum it all up:
swing link
[ March 04, 2002: Message edited by: Roy Ben Ami ]
mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
it says it all Roy. roy, you need to author a book. your explainations are to the point and would be very helpful to give the full worth of buying a book !!!
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
thanks Mark!
im glad you find it helpful!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Mark,

Welcome to the wonderful world of Swing!

Roy Ben Ami has already pointed out most of the differences between Swing and AWT... but the best way to learn is to do it!

I would go through Sun's Swing tutorial first - link here. This will give you a good overview of Swing.

Then, I would work on making simple GUIs using the "J" versions of AWT components.

Then I would start learning some of the more difficult components like JTree and JTable.

The best book I have found on Swing so far is David M. Geary's "Graphic Java 2 - Mastering the JFC : Vol II - Swing". However, I would go through the tutorials first... the book is great for high level stuff, but not too great for just starting out. I'm still working my way through it (it is a biiiig book!), but it gives new insights an useful information in every chapter...

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
GeeCON Prague 2014
 
subject: learning swing ....