Java GUI - Accelerating the Learning Curve

I will be cranking my first serious GUI in Java here for the next few weeks / months. This will be my first Java project where I will adhere to a very high standard for coding methods and results, so I expect the learning process to take some time.

I would say that I am not entirely new to Java, but more of an intermediate user accustomed to the API, still uncomfortable with a few keywords. I like OOP mainly due to PHP development.

Are there any tips people can come up with to speed up the learning curve, ie “don't do this” or “I wish someone would tell me this” type of thing.

The first one I ran into on a few other questions was the null layout manager - apparently this is crappy programming and gets in trouble on the line. So this helps me right away, maybe save a week and rewrite a little right there.

Another was using NetBeans to navigate to Swing ... but I can't go into detail on that, you need some research.

Are there any other strong guidelines out there?

0


source to share


7 replies


You might want to check the following:

JGoodies has the famous FormLayout and other stuff: http://www.jgoodies.com/

SAF JSR-296 fork: http://kenai.com/projects/bsaf/pages/Home

Apache Commons, especially lang, if you are not using them already, you are wrong: http://commons.apache.org/



Not sure about SwingX right now, but it seems worth looking at as well: Does anyone use "swingx"? extensions for Swing?

Java practice, general good stuff: http://www.javapractices.com

You should definitely study the existing framework and tools. It helps to read a lot ahead to get the picture instead of delving into a lot of writing. Almost everything that exists, except for a library for general translations in desktop applications, for example. for general actions (menu items).

Edit: Ah and don't forget SwingWorker ...

+3


source


Are there any other strong guidelines out there?

Also on the general topic of layouts, don't waste time looking for the "right" layout when a combination of nested layouts will produce an effect. See Nested layout example for code example.



Jaqap.png

+4


source


If you are using Eclipse you can try WindowBuilder Pro which is a GUI designer, now open source and part of the Eclipse project. The code he created is extremely readable. Honestly, with this tool I will no longer be doing UI development. These are Swing and SWT, among others. Many powerful layout managers are also supported (including MigLayout!).

enter image description here

+3


source


Another was using NetBeans to navigate to Swing ...

I'm not a fan of using an IDE to generate, because okay, now you are tied to the IDE and you cannot navigate from IDE to IDE.

You are forced to follow the structure of the code they generate. I like to have complete control over the code.

+2


source


Not specific to UI programming, but I highly recommend you read Effective Java .

+1


source


Swing is just a GUI API (and anything related to GUI programming like MVC is applicable and the topic is well covered in the CS literature).

Just pay attention to the following caveat (which really applies to most GUI systems out there, as it makes the task of writing such libraries much easier):

It is an "active subsystem" that has its own dedicated thread. Share problems with swing threads, how to use SwingWorker, etc.

As far as the tools I last checked, NetBeans was king of the hill on land Swing (but that was pre-ora). If you don't like this tool, do a favor and at least create a sample app and see how the IDE organizes your app for you. There is a boat with collective knowledge.

+1


source


I really like the GridBagLayout. Flow and Box Layout also know and group layout well if you have Java 6. NetBeans IDE has a really intuitive GUI manager, but the way it encodes things is a little odd. Of course, layout zero has the most flexibility, but it's not a good practice as you said, and besides, with these layouts, I doubt you would need more functionality except in rare cases.

+1


source







All Articles