2

I've written a lot of Java applications over the years, but the vast majority of them have been simple command line programs with only a few hundred lines and (at most) several classes.

My question is this:

How do I now design/code an interface to this application?? Where do I start? I mean are there any tutorials/resources which describe the steps involved? I know Swing exists, but where do you start, and is it the only option?

Any help/assistance appreciated...

3
  • 3
    First I think you'll want to decide how you want to deploy the application. If a desktop application, then yes, Swing can work well for you. If it's to be a more distributed application then other ideas might work better (?JSP? but the latter is out of my area of expertise and so I won't give any more specific recommendations for this). If you decide on Swing, then you'll want to check out the tutorials. Commented Jan 13, 2012 at 3:43
  • Added the 3 rich client GUI toolkits to the tags. Commented Jan 13, 2012 at 4:33
  • Java Web Start is a good deployment option. Commented Jan 13, 2012 at 5:05

3 Answers 3

9

The rich client GUI toolkits for Java are basically:

  • AWT Sun's Abstract Window Toolkit was the original component kit for making GUIs, a toolkit based around using native components. AWT still contains the core of very important parts of J2SE GUIs such as Graphics/Color/Java 2D, Image & BufferedImage, printing, D'n'D..
  • Swing The current, main-stream desktop app. component toolkit. Swing generates the components internally, and allows setting a Pluggable Look and Feel to the GUI. Swing offers components & functionality not available in AWT such as JTable, JTree, support for formatted documents (e.g. RTF & simple HTML) in Swing components.. For more information see things that Swing provides beyond AWT.
  • Java FX 2 Intended as an (eventual) replacement to Swing, AFAIU.
  • SWT is another choice, not written by Oracle, uses natives. I would not recommend it for someone learning rich client programming, since it is a lot easier to get answers in relation to Swing.
Sign up to request clarification or add additional context in comments.

5 Comments

I strongly recommend SWT instead of Swing too. Eclipse RCP is still more mature than Swing application framework. And one of the most important reason for me is font rendering of Swing/AWT in Linux is horrible.
@wyz Perhaps you need to look into setting the run-time AA font setting or other font related settings.
@AndrewThompson I have tried various settings. It will improve, and definitely cannot the native rendering. If you could achieve it, please post a snapshot and let me know your settings. I'm more than happy to know the trick. (BTW, font rendering is the main reason from me trying JetBrain products in Linux as I cannot stand the font).
"please post a snapshot" What good would a snapshot of my Windows 7 machine do?
@AndrewThompson Font rendering in Windows is acceptable to me. My issue is with Swing in Linux.
5

You have to learn core GUI API java.awt and its sub-packages along with (extended API) javax.swing and its sub-packages. You may start - The Java Tutorial.

3 Comments

But ignore the AWT components and use Swing.
@AndrewThompson - Appreciate! Only few components of AWT, especially Widget components - Label, TextField, Frame, Panel etc should be avoided but not a whole AWT API/events/layout/print/graphics.
With that clarification, we are in agreement. Swing is heavily based on the non-component parts of AWT packages (and based in small part on/inherited from a few AWT components).
2

No, Swing is not the only option but it is where you should start. Swing is the "new and improved" version of some of the GUI objects in java.awt. Most of the Swing objects build off of their AWT counter parts our are completely new. Both Swing and AWT are a part of the core Java API so it would be best to start with the tutorial that AVD linked you to (The Java Tutorial)

1 Comment

JTable, JTree, support for formatted documents in Swing components.. This kind of stuff goes beyond "new & improved", since AWT provides no similar component/functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.