Friday, August 19, 2005

Swing and the client...

For the last week and a half I have been on a java gui project... I had to wipe away the cob webs entangled in my swing knowledge.

I read somewhere months ago about how Java's uptake ont he client was not as much as could be expected. I cannot remember the answer to this question. Having spent the last week and half building java guis, I'm pretty sure I know why.

Fundamental to building a gui is the laying out of gui components. Java eschews the absolute positioning and sizing of a gui in favour of the concept of a layout manager. This is a laudable goal, and I understand why they went this route. I agree with it to be honest. In a multi platform environment you do not know how an absolute size location on one platform will appear on another. What about when the user wishes to resize? What happens then when using the abolute system. What if you want to let the user resize? Proof of this is evident in that there is no XYLayout provided in java!

However, laying out components with the managers provided is a black art. To get the gui to look exactly the way you want it takes a lot of hair pulling. Just to get a component to move to the left by 5 points can sometimes take up to 2 hours. Just to get a gui to resize in the way you desire could take half a day.

I start building a simple gui, using one of the simpler layout managers. Eventually, the gui just won't work, and I have to use GridBagLayout. As far as I'm concerned, this is overkill, but I don't have any choice. I'd rather _not_ use it, but what can you do?

It does not have to be this way.

I have used the SWT Formlayout and find it GREAT! I wish that someone would be so kind as to port the SWT Formlayout to Swing. I have taken a short look at the java FormLayout (jGoodies). I will consider that manager and the Table Layout manager. Maybe they will work better.