Forums Register Login

Strange GUI Coding

+Pie Number of slices to send: Send
I downloaded Eclipe's Visual Editor today to see if it was any good. While testing it though I noticed something I found strange. Here is a code snippet



Anyone else code GUI's this way?
+Pie Number of slices to send: Send
besides some examples from sun java tutorial (and some text books too) i never saw swing code for real; so i wonder if eclipe's code is recommended.

Is it really that bad? Does other IDEs code swing better? or is it a common problem to IDEs generation code?

do you recommend hand code swing instead?

TiA
+Pie Number of slices to send: Send
I prefer to handcode my GUIs in Java - I like the control that gives me. In my limited experience, GUI-editors almost invariably create much more complicated code, which makes it harder to maintain the GUI (which is the main work in software development!).
+Pie Number of slices to send: Send
 

(...) to maintain the GUI (which is the main work in software development!).

+Pie Number of slices to send: Send
 

Originally posted by miguel lisboa:



Maintenance in general, I meant, not maintaining GUIs...
+Pie Number of slices to send: Send
i kept GUI in order to not change your words, but i understood you refered to code in general

anyway now that i think of it, one does this program, then passes another 5 or so years making updates to it or fixing bugs or both ...
+Pie Number of slices to send: Send
 

Originally posted by miguel lisboa:

anyway now that i think of it, one does this program, then passes another 5 or so years making updates to it or fixing bugs or both ...



Exactly! If a program gets used, people will find things that can (and should) be improved. People will get ideas for new requirements. They will want to use it for new problems. Other people will want to use it, but they will have slightly different requirements. Etc. pp.

The very most important property of a software system is its maintainability. Whole companies go bankrupt because they don't consider this important reality.
+Pie Number of slices to send: Send
The few times I developed a Swing client I started with Netbeans or IBMs Visual Editor which is now part of Eclipse.
I allways ended up with hand-coding. Took some useful ideas how to strucutre the code from examples on JGoodies.com (Forms demo) as I am using their (or better his?) Look & Feels and Layout manager anyway.
The Gui subproject at my current main customer uses self written code generation from xml files to build guis. Have some doubt, if they are not perhaps ending in lack of flexibility/messy maintainabiltity problems with this approach, though.
Now Scott Delap new book on sourcebeat should contain some expedient guidelines to follow.
[ May 01, 2005: Message edited by: Axel Janssen ]
+Pie Number of slices to send: Send
If you're referring to this "lazy initialization" method, then yes I code my GUIs that way. It makes it easy for me to figure out where the initialization code goes for a particular component. If I want to know why my "Ok" button looks/behaves the way it does, I look for the getOkButton() method. I'm not saying it's the best way in the world, but it has worked well for me and makes maintenance quite easy.
+Pie Number of slices to send: Send
 

Originally posted by James Carman:
If you're referring to this "lazy initialization" method, then yes I code my GUIs that way. It makes it easy for me to figure out where the initialization code goes for a particular component. If I want to know why my "Ok" button looks/behaves the way it does, I look for the getOkButton() method. I'm not saying it's the best way in the world, but it has worked well for me and makes maintenance quite easy.



What we do in such cases is have a createContent method, which might delegate to a createOkButton method. Those methods are only called exactly once. Most often simply is no need for the increased complexity of lazy initialization, in my experience.
+Pie Number of slices to send: Send
I don't know about the complexity of lazy initialization, but as I said I'm not saying it's the best way. It just works for me. I actually don't do much of that type of coding anymore. I wrote a class which allows me to specify my GUIs using an XML document (looks like HTML tables) using GridBagLayout. It even supports binding event listeners to the components. The event listeners usually just call methods on a controller object. This binding is all done using OGNL. That is how I usually code these days. It seems to be much simpler.
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 962 times.
Similar Threads
refresh a jtable
refresh label
centering a dialog
Help with response function
JScrollPane Frustrations
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:55:54.