alanwilliamson

Layout Managers, sometimes you have to get your hands dirty

Last night I went through the hell of attempting to layout some controls on my JPanel. I'll freely admit, I was struggling. I was trying to use the Visual Editor for this and forcing myself not to drop to code. I failed. I wanted to layout some basic controls for a fairly mundane input dialogue box. I tried them all to see which one was going to offer me the easiest way of doing it. In my heart I knew I needed the GridBagLayout, but the UI wasn't permitting the sort of control and flexibility I was hoping for.

In the end I gave up. Resorted to hand coding the GridBagLayout positioning as I wished. For the HTML experts among you, laying out controls using GridBagLayout is very similar to how you would use an HTML table for positioning. If you find yourself struggling to get the look you are after, then think how you would do it with an HTML table and you'll be more than halfway there. GridBagConstraints gives you the sort of the control you would find in TD and TR tags of the HTML table.

It is a shame the Visual Editor let me down there, I was hoping that I could have done the whole thing via drag'n'drop. Visual Studio from Microsoft doesn't seem to suffer from the same short comings, allowing me to drag'n'drop with extreme ease to produce a layout that will work in all window sizes. Visual Editor has brought a huge boost to the Eclipse world, it still has a little way to go. I'll freely admit I have no idea what the likes of Borland and IntelliJ do in this arena.


 

Recent Cloud posts

Recent JAVA posts

Latest CFML posts


 
Site Links
Recommended Sites/Blogs

Follow arwilliamson on Twitter