I've been trying to design a more or less working model of a GUI so that I can discuss what's needed, not needed, and other changes to be made with the primary user. I've been using WindowBuilder and am frustrated as the code it generated is often muddled. I've been able to clean up much of it without a complete understanding of it and hope that someone who understands the "cleaned up" code will comment on it. It appears to display correctly now on this LINUX Ubuntu development machine but before I worked to attempt to clean it up I ran it on OSX where it failed.
This is used to layout a panel with a single JLabel, "alt-Commands" near the top, followed by pairs of JLabels all more or less centered in the panel. This is a kind of menu to show key combinations that do things. It looks something like this (I see by the preview that Java Ranch abhors consecutive spaces):
I've been using WindowBuilder and am frustrated as the code it generated is often muddled
Not sure this is particularly WindowBuilder's fault as I imagine it's pretty hard to programmatically generate easy to read code to layout components.
Personally I never use GUI builder tools for this very reason and it doesn't take much effort to write the code yourself once you get to know your way around the common layout managers and how to combine them.
It appears to display correctly now on this LINUX Ubuntu development machine but before I worked to attempt to clean it up I ran it on OSX where it failed.
In what way did it fail? Did the program crash, the screen not display, were the components not where you expected them etc.
Joined: Feb 22, 2010
I don't understand this layout but an certain that if I have several rows each with two JComponents that the code should be regular, too. But it was not. If I try to align the left edges of the left components in the first row it won't work for many of them. Same for aligning the top edges. This causes some problems although it displays correctly on the development machine (LINUX) but it fails to display correctly on OSX and it affects sizing of the enclosing container.
I especially don't understand the lines 2 though 5. It appears to me to be too many groups. And this is code that I've edited that was far worse.
I come from a long experience with Borland C/C++ and Delphi where the WYSIWYG editor works well so it was a shock to find that Java had layout managers which I needed to learn as well as Java to get a Frame to display correctly. I've hand edited the layout created by WindowBuilder for some of my containters and have more to go. It's tedious and the kind of work a computer should be doing IMHO. It's also strange that when I display the form, then look at the Design and then back to the code I find that it may have been changed for reasons that I don't understand.
I'll see if the GUI displays correctly on OSX when I'm finished.
Joined: Aug 07, 2007
I don't understand why you are even trying to "tidy it up".
It's generated code, you aren't supposed to manually edit it. If you want to make changes you are supposed to go back to the builder and use that to edit the code.
subject: Look at my code snippets WindowBuilder Layout