Java GUI tutorial

Hi there!

Could you please suggest a good tutorial about creating GUI with Java?

I know the basic technique from official Sun swing tutorial, and i do not need any recomendations on how to put a button on the panel.

But I realy want to improve the architectural design of my GUI apps. Currently my code looks like a heap of swing calls and it is definitly not what people call OOP. Well maybe someone can suggest a tutorial like “creating a good GUI code with Java”.

BTW, how you implement your GUIs? Do you use some designer applications or do all this things manually?

Have you looked at the Action Framework yet?

http://java.sun.com/docs/books/tutorial/uiswing/misc/index.html

[quote]BTW, how you implement your GUIs? Do you use some designer applications or do all this things manually?
[/quote]
I would suggest using the Netbeans GUI editor. While some people don’t like Netbeans as an IDE, the GUI-Editor is by far the best one I found for Java. Keep in mind that you have to include an extra Jar for GUIs created with the new Matisse (Group-Layout). You can avoid that by using the traditional LayoutManagers (I prefer GridBagLayout), but layouting them visually is not as nice as with the new one.

More information here: http://www.netbeans.org/kb/articles/matisse.html

unfortunatly in my experience using Swing is a bunch of calls as you say Juriy… I hate it.
btw. I’m using SpringLayout, IMHO the best standart layout.

[quote]I’m using SpringLayout, IMHO the best standart layout.
[/quote]
Currently I’m using null layout :slight_smile:

Okay… Just few more architectural questions… Do you guys use separate classes to adequatly manage GUI parts like main menu, or dialogs, or just put it all together in one class? Maybe there is some design patterns for GUI? I’ve got a strong feeling that I’m trying to invent a wheel, when I experiment with different GUI approaches like MVC (I don’t like it very much)…

null layout :-X this better be for a game.

offcourse you seperate your gui over and amount of classes, one big class is unmaintable/error prone. null Layout makes your layout static, limiting the amount of screens that your app is workable under greatly. See websites and absolute sizes.

you have to decide if you go the WYSIWYG editor or simply code it.

I take gui parts generaly in two ways; I have building blocks eg components, or parts that (pritty much) follow the navigation hierarchy. I used to have plain action listeners to capture functiononality (which tries to follows usecases/senario’s) since that lead to cumsyness with respects to states… anyways I then noticed the swing Action’s and all was well.

that takes part of the coding end and then you have to scratch your head how to increase the accessability of your application.

Only use null layout when you have full control of the sizes of your components, down to the pixel. If you allow anything to be it’s “natural” size then a null layout is likely a bad idea.