Skip to main content

Enhance/fix GridBagLayout somewhat

8 replies [Last post]
mgrev
Offline
Joined: 2003-08-12

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)

Cheers,
Mikael Grev

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
denismo
Offline
Joined: 2003-06-28

Yes, we do

mgrev
Offline
Joined: 2003-08-12

Great. :)

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."

That's it for today.

Cheers,
Mikael Grev

denismo
Offline
Joined: 2003-06-28

Please note that we are just [b]considering[/b] Docking layout, nothing more :)

Anyway, I'll pass your comments to Swing engineers.

mgrev
Offline
Joined: 2003-08-12

> Please note that we are just considering Docking layout, nothing more

I know, though I recon I won't get a better chance to inject my thoughts on this particular issue. :)

denismo
Offline
Joined: 2003-06-28

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.

mgrev
Offline
Joined: 2003-08-12

Ok, that is a good reason. Are you considering a Docking layout?

zander
Offline
Joined: 2003-06-13

> Ok, that is a good reason. Are you considering a
> Docking layout?

URL?

mgrev
Offline
Joined: 2003-08-12

Sorry, I know of no one. I was thinking they'd make thier own, or why not hire me to do one for them? You'd vouch for my coding abilities, right? :)