🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #75459

Re: Nested GridBagLayout and its pitfals

#75459
From: Pathetic Girl
Date: Sun, 11 Mar 2007 00:49
156 lines
7271 bytes
In article <GpGdnUccyNzl2FbYnZ2dnUVZ_tunnZ2d@comcast.com>, "Larry Barowski"
<MElarrybar-AT-eng_DOT_auburnANOTHERDOTeduEND> wrote:
>
>"nukleus" <nukleus@invalid.addr> wrote in message
>news:eqfboa$1llq$1@sage.ukr.net...
>> Use GridBagLayout for each of those panels.
>> For the group of checkboxes, GridBagLayout is not
>> the best choice as it does not guarantee the equal
>> Y offsets between the checkboxes.
>
>I'm not sure what you mean by this. Of course
>you can get equal y offsets or y spacing. Maybe
>you meant "X" here?

Yep.

>> So, for check box panel, use GridLayout instead
>> as it will guarantee the equal X size distribution
>> between all the checkboxes.

>If you have some checkboxes with long labels
>and some with short labels, you may not want
>equal spacing in X.

Well, than this issue does not apply to your situation.

>> 4. Try to keep all the values of constraints structure
>> at zero instead of filling them with values you THINK
>> will make it look better. Use only those parameters
>> that you feel are absolutely necessary, such as insets.
>>
>> The exception is the row/column numbers and a number
>> of cells you want your GUI element to occupy in X or Y
>> dimension.

>I think for most layouts it's better to place components
>left-to-right and top to bottom using gridwidth=REMAINDER
>to end a "line". The layout is easier to modify that way.

>> Forget about the minimum and preferred sizes.
>> They are virtually useless. If you do your
>> design correctly, you'll have the absolute
>> minimum of variour parameters to be set
>> as far as boundaries, sizes, etc.,
>> behaving the in the most predictable way
>> possible under the Sun.
>
>Sometimes you need certain components to be
>shrinkable to zero size to get the effect you want,
>so setting a zero preferred and minimum size of
>zero in one or both directions is useful.
>
>> Some claim that by using some proprietary
>> layouts, they can save half the amount of code lines,
>> which is about the funniest argument possible.
>
>By wrapping GridBagLayout in a helper class that
>does the common things I need, I probably save
>75% of the size of the gui part of the source code,
>and a lot of space in the class file as well. It also
>keeps my layouts consistent by enforcing common
>spacings, etc. Most of my GridBagLayout code
>uses one line of code for each component added,
>and that is a method call with two parameters.
>For example (part of one layout):

It'll break your GUI designer, if you use one.
Otherwise, just write it all by hand.
Good luck on that one.

>panel.addLabel("Color", GBLPanel.ANCHOR_EAST |
>   GBLPanel.FLUSH_BOTTOM);
>panel.add(color_setter, GBLPanel.ANCHOR_WEST |
>   GBLPanel.HOG_WIDTH | GBLPanel.FILL_HORIZONTAL |
>   GBLPanel.FLUSH_ALL);

>If you are doing a large amount of gui code using
>GridBagLayout, creating such a helper class is
>well worth the effort.

The problem is that you are talking about making
things by hand, which I, personally, do not support.
At THIS stage of the game, you'd better have some
automation.

>> 12. Try not to use weights, if at all possible.
>> If your frame has several groups of GUI elements,
>> each having several elements, then what you think
>> is space distribution may end up being utterly
>> different in run time and you'll waste hours if
>> not days, trying to play with those weights.

>Having zero weights can cause strange effects.
>Always use weights, but choose from a limited set.
>Normally you have some group of components
>that together should use all of the extra height or
>width (text fields, text areas, sliders, editable combo
>boxes, lists, etc.) and others that should have a
>fixed size (labels, buttons, etc), and you can get by
>with always using a weight of either 1000000 or
>..000001.

That is another problem, the inconsistency of behavior.
In some instances, changing weight from 0 to 0.00000001
changes the behavior in such drastic manner,
it is well beyond comprehension.

>> Use as few parameters in your constraints structure
>> as possible.

>Use mostly consistent parameters, and few choices
>for weights and spacings.

>GridBagLayout does not play well below preferred
>size. Consider only using it within a scrolled pane
>or a window that is not shrinkable below preferred
>size.

>Creating your own layout manager is much simpler
>that you think. For some reason people will spend five
>hours fiddling with GridBagLayout or SpringLayout
>trying to get it to do something it wasn't meant to do,
>when they could write a custom layout manager in
>under an hour.

If they had enough experience to do that.
But, no matter what is the situation,
writing a GUI class by hand seems to be like a joke
considering where we are. It is like writing an app
with a hex calculator. Sure, some experienced users
will be able to do it, but even there, if you want
to change some things in the future, your scull may
crack trying to read back your own code if your
frame is complex enough. That is why there are GUI
design tools on the first place.






- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[NWO, Skull and Bones, propaganda, brainwash, mind control,
fanatic, deranged, idiot, lunatic, retarded,
religion, God, pro-life, President, freedom]

Q: What makes you believe there is life?

"My pro-life position is I believe there's life.
It's not necessarily based in religion.
I think there's a life there.
Therefore the notion of life, liberty and pursuit of happiness."

--- Adolph Bush,
    Quoted in the San Francisco Chronicle, Jan. 23, 2001
Technical Details
Message-ID: <07F87F71.EE19B28B@52.197.24.235>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!novia!feeder.news-service.com!xlned.com!feeder1.xlned.com!npeer1.de.kpn-eurorings.net!npeer-devel!news.kiev.sovam.com!Svitonline.COM!nntp.ukr.net!news.tsystems.kiev.ua!info.elvisti.kiev.ua!news1.lucky.net!carrier.kiev.ua!news.te.net.ua!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny04.POSTED!760c3fd9!mindspring.com!reliable
References: <eqfboa$1llq$1@sage.ukr.net> <GpGdnUccyNzl2FbYnZ2dnUVZ_tunnZ2d@comcast.com>

Show Full Headers
Complete Article Headers
Message-ID: <07F87F71.EE19B28B@52.197.24.235>
Subject: Re: Nested GridBagLayout and its pitfals
Date: Sun, 11 Mar 2007 00:49:24 GMT
From: Pathetic Girl <reliable@mindspring.com>
References: <eqfboa$1llq$1@sage.ukr.net> <GpGdnUccyNzl2FbYnZ2dnUVZ_tunnZ2d@comcast.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!novia!feeder.news-service.com!xlned.com!feeder1.xlned.com!npeer1.de.kpn-eurorings.net!npeer-devel!news.kiev.sovam.com!Svitonline.COM!nntp.ukr.net!news.tsystems.kiev.ua!info.elvisti.kiev.ua!news1.lucky.net!carrier.kiev.ua!news.te.net.ua!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny04.POSTED!760c3fd9!mindspring.com!reliable
Newsgroups: news.groups, alt.slack, alt.config, news.software.nntp, alt.usenet.kooks
 alt.usenet.kooks
Organization: Lion Enterprises
Lines: 156
NNTP-Posting-Host: d31-75.tenet.odessa.ua
X-Trace: toster.te.net.ua 1173596549 16000 195.138.75.31 (11 Mar 2007 07:02:29
 GMT)
X-Complaints-To: abuse@te.net.ua
NNTP-Posting-Date: Sun, 11 Mar 2007 07:02:29 +0000 (UTC)
X-Newsreader: Microsoft Outlook Express 4.72.3110.1