Java GUI Development

June 19th, 2007 by peasleer

I’ve inherited a decently complex graphical interface to add functionality to, all written in Java. The previous developer who originally designed the interface (and who is also no longer with the company) used NetBeans to accelerate the process. While not bad in itself, the results are horrifying.

I now have a couple hundred lines of variables named along the lines of “jPanel18″ and “jTextField3.” There are three separate layouts being used across the many panels. Not a comment is to be seen, except for what was provided by NetBeans’ auto-generated comments, which have nothing to do with the code and everything to do with “this is auto generated, don’t edit.” To make things worse, the form file that accompanies the source for NetBeans is almost two years out of date, and a lot of functionality and structure changes have occurred since then leaving me to do all the editing by hand.

Tips I suggest for those thrown into situations like this:

  • Put a TitledBorder around each panel with the panel’s name. Now that you know which panel goes where, write it down.
  • Seriously, draw a picture. When working with generically named components, you’ll appreciate having a ‘map’ of where everything is going.
  • Refactor. If you can rename the components without breaking things, give them useful names (Eclipse makes this easy). If nothing else, move the components into groups of functionality or physical geometry in your initialization method.
  • Read up on the layouts being used. If you know how to work with the layouts within a panel, you’ll spend more time coding and less time making a single modification, rebuilding, and running your application to see how the change affected things.
  • Learn from this painful experience, and don’t do this in code you write in the future.

May you be blessed with patience. You’ll need it.


0 Responses to “Java GUI Development”

Feed for this Entry Trackback Address
  1. No Comments

Leave a Reply