Tom
Tom

Reputation: 9643

How to learn Java Swing and make GUIs quickly?

I've been coding in Java for the past year, and i think I have solid OO and basic OOD skills. I'm looking to build a Java GUI on-top of an existing project which is not complex, but I want to finish it as quick as possible. So I'm looking for an API that would abstract all the nitty gritty implementations and let me focus on the core of my minimal viable product.

I really prefer coding with eclipse and not wasting time trying to learn to get used to another IDE. What would you suggest I do?

Upvotes: 7

Views: 10704

Answers (4)

adrix89
adrix89

Reputation: 498

Here is the crash course in swing.

First thing to learn is the layout managers.This is the big hurdle, they are finicky things and you have to master them.

Second is listeners,without them nothing happens.

Third is the JComponents themselves,you will slowly learn them as you go along. I would recommend using NetBeans GUI builder to play with them and get a feel for them.

Note that most JComponents have different models you can use rather then the default.

Also the only difference between JPanels and JComponents that I can find is that JPanels have layout managers.

A good place for various swing hacks and tutorials is here:

 http://www.java2s.com/Tutorial/Java/0240__Swing/Catalog0240__Swing.htm

 http://www.java2s.com/Code/Java/Swing-Components/CatalogSwing-Components.htm

Upvotes: 12

Marko Topolnik
Marko Topolnik

Reputation: 200166

I think you'll find out that there is no royal way to GUI in Java. Every approach is a pain in the (*). Even if you use a visual GUI builder, it will STILL be a pain in the (*). As a long-term investment in your skills, I recommend you to bite the bullet and learn to build the GUI programmatically. That's what every experienced Swing dev does anyway, so better head for that goal straight away. You could also start with SWT/JFace, but that APi is more difficult and quirky than Swing. RCP adds yet another layer of quirkiness and complexity over SWT/JFace, so I'd stay away from that while still a beginner, and in fact at all times except if making a massive GUI application.

Upvotes: 4

Andreas Dolk
Andreas Dolk

Reputation: 114787

Sounds to me that eclipse RCP could be your friend (if you're looking at a rich client solution). Just grap a distribution of eclipse for plugin development (much faster than installing the plugins to your existing copy), create one of the sample projects and start hacking.

For web applications, I'd recommend the playframework. It integrates quite well with eclipse.

Upvotes: 2

Radu Murzea
Radu Murzea

Reputation: 10900

Well, actually the GUI Builder in Netbeans is your best bet to make a GUI really fast. You can do it in a matter of minutes if you have the picture in your head about how it's supposed to look like. After that, the only thing left to do is to bind it to your application; more specifically: make the ActionListeners of your buttons for example do whatever they should.

This of course depends on the application's size. If it's small, then making a GUI for it is easy. If, on the other hand, it has 2000 classes, then it can be more complicated, since the GUI will probably be more complicated.

If the application can be modelled as a Model-View-Controller architecture, that would help you a lot.

Upvotes: 6

Related Questions