Using MiG Layout For Better Swing DevelopmentApr 29, 2008 · 1 minute read · Comments
I have forgotten a few libraries in my Better Swing Development article, and notably MiGLayout.
GridBagLayout is too verbose, and still feels too clumsy. This is why a while back I wrote a small tool to help visualize various GridBagLayouts for people who are not used to it. But it would have been much simpler to use a better layout instead.
MiGLayout is good, I managed to have good results without almost any practices on not so simple layouts. It also makes the code more concise.
Related to my previous post about SwiXml, and as SwiXml does not yet support MiGLayout, I was thinking how easy it would be to achieve something relatively similar. With proper code conventions it is quite easy to describe the GUI outside a Java file, for example, for an easy start in a Beanshell file.
The beanshell file would contain components construction, and MiGLayout of them afterwards, that’s it. All listeners and component behaviours would be kept in java classes. With this kind of code split. The beanshell file is then extremely simple, as simple as the SwiXml.
MiGLayout also has plenty of extra functionalities like “hidemode 1” that can help automatically redoing the layout if a component becomes visible/invisible.