Enhance/fix GridBagLayout somewhat

You are here:

I know that there are OpenSource layout managers that are better, but I find GBL good, though it has its quirks.

Hands on:

1)
In the constructor of GBL make it possible to align the whole layout package. If the components handled by GBL doesn't span the whole of its containers layoutable aread it is very hard to align the whole 'package'. Add a constructor GridBagLayout(float alignX, float alignY), or even better GridBagLayout(RefValue alignX, RefValue alignY) where RefValue can denote:
* an absolute pixel distance from top/left edge or
* an absolute pixel distance from bottom/right edge or
* a relative (as the float example) distance in percent (0f..1f)

2)
Change/fix the behavior so when the preferred size can't be allocated to a component it doesn't get the minimum size automatically, but the largest possible size it can get, that still satisfy all constaints. (I.e. Something between min and preferred size)

Can I just offer some fuel for thought, maybe you can send this to the guy that possibly will code it.

* The size of the docked component should be able to be set in a DockConstraint object, and any information not set in that constraint is collected from the docked component. This would make it possible to have both container and component managed sizes.

* Size constraints in the "docked" dimension should be very flexible. Min/Pref/Max of course but they should also be able to be specified in absolute pixels OR percentage of parent containers size OR (possibly) other units (Dialog Units, Inches, Millimeters).

* With above there would be possible to specify (for instance) "preferably 40 pixels wide, but never less that 10% of the remaining size and never more than half"

* Gaps around a docked component. A pixel gap for every docked component. Might even use an Insets or a Border here. The main thing is that one should not need to set the border/inset on the docked component itself, since that component should be totally shielded from this layout logic. The component might be a Bean that is docked for instance, and you just wants a litter space, or a border around it. That bean might have a border of it's own, and wrapping that in a compound border is not very nice. Very easy and light weight to implement. This would also make it possibly to have logic at the preferred level, container and/or component.

* The algorithm for finding out max/pref/min sizes for an arbitrarily complex docked component array is not hard, but can be tricky. Contact me if you can't find a good one, I've just made a docking layout for my lightweight component suite.

* Make the DockingConstraint:s 'controllable'. This would very much increase the number of use cases that this layout manager absorbs. If the constraints are controllable (i.e. dynamically changable), they can in effect do most of what today needs to be done with a SplitPane, without nesting panels which SplitPane does. It would for instance be very easy to make a custom "control knob" for adjusting the docking panels' size. If you don't follow me on the possiblilities that this opens up for, mail me on "swing >at< miginfocom . com."

GB has so many problems, fixing some them would not solve overall pain from its usage, but might introduce backward-incompatibility problems. We'd rather create something more useful, more powerful, and, hopefully, more usable... Until then, use combinations of layouts or third-party layouting monsters.