This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 8304 - Cannot add glue or struts to component with BoxLayout
Summary: Cannot add glue or struts to component with BoxLayout
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: All All
: P3 enhancement with 4 votes (vote)
Assignee: issues@guibuilder
URL:
Keywords:
: 23549 28617 37934 (view as bug list)
Depends on:
Blocks:
 
Reported: 2000-11-09 02:17 UTC by Robert Baruch
Modified: 2011-10-11 13:13 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Baruch 2000-11-09 02:17:56 UTC
The thing which makes BoxLayouts really useful is the ability to add horizontal
or vertical glue or struts (from the Box class) to make other components lay out
as wanted.

If you have a JPanel with a BoxLayout in the form editor, there is no way to
create a glue or strut component.
Comment 1 Tomas Pavek 2000-11-09 14:11:59 UTC
Those "glues" and "struts" are just simple empty components with minimal,
preferred and maximal size properly set. It's quite easy to make them e.g. from
JPanel.
Glue: min. size [0,0], pref. size [0,0], max. size [32767,32767]
Horiz. strut: min. size [w,0], pref. size [w,0], max. size [w,32767]
Vert. strut: min. size [0,h], pref. size [0,h], max. size [32767,h]
(32767 is max. short number - it means that in given direction JPanel may grow
to any size - then it's a glue; constant number makes a strut...) Glue and
struct can be even combined (e.g. glue with minimum size).
So I think there's no need to hack some special support for javax.swing.Box.
Comment 2 _ ttran 2000-11-29 19:06:59 UTC
this is a comment from Tom Ball posted on nbui list


From: Tom Ball <Tom.Ball@sun.com>
Subject: Re: [nbui] compliance to Java L&F Design Guidelines by default
To: nbui@netbeans.org
Date: Tue, 28 Nov 2000 11:25:28 -0800

[unrelated text deleted -ttran]

I actually don't care about support for the BoxLayout, but instead
proper support for javax.swing.Box.  It isn't listed as a Swing
component, yet its use in a form editor is a natural.  Drop components
inside of a box, then drop glue or strut components between them.
Although glue and strut components are defined as having no view, in a
form editor they should look like an i-beam for a strut and possible a
spring for glue (springs were what NeXTStep used).  You want to change
the length of a strut?  Just drag it longer or shorter.  You get the
idea.

In http://www.netbeans.org/project/www/www-nbbugs/msg02269.html, Tomas
Pavek closed an enhancement request for struts and glue, stating that
it's equivalent to use JPanels with min, pref and max size methods
defined to emulate struts and glue.  Aside from this being way too much
work and not visually obvious, he misses a basic point:  Filler
components (struts and glue are fillers) were specifically designed as
non-Swing lightweight components to reduce their memory footprint.  They
are not the same as JPanels, and were created because layout using boxes
can create forms with very large footprints.

Perhaps I can hack up a quick demo so you can understand how much easier
and more intuitive visual editing using boxes can be.  The main reason
Box was added to Swing was to help IDE vendors by providing a standard
for them to work with.

[unrelated text deleted -ttran]
Comment 3 Marian Mirilovic 2001-05-29 12:42:42 UTC
Reopen as enhancement, we have this in nice-to-have features list for NB 3.3
Comment 4 Jan Chalupa 2001-11-27 12:38:31 UTC
Target milestone -> 3.3.1.
Comment 5 Tomas Pavek 2002-05-28 10:55:06 UTC
*** Issue 23549 has been marked as a duplicate of this issue. ***
Comment 6 Marek Grummich 2002-07-22 09:58:46 UTC
Set target milestone to TBD
Comment 7 Marek Grummich 2002-07-22 10:02:52 UTC
Set target milestone to TBD
Comment 8 Tomas Pavek 2002-11-11 10:38:21 UTC
*** Issue 28617 has been marked as a duplicate of this issue. ***
Comment 9 Tomas Pavek 2004-03-01 19:04:24 UTC
*** Issue 37934 has been marked as a duplicate of this issue. ***
Comment 10 Tomas Pavek 2005-05-16 18:26:05 UTC
This makes sense, however with the new layout design support becomes less
important. Changing target milestone to future.
Comment 11 _ wadechandler 2005-09-14 18:17:09 UTC
You can rob my code from the JDNC incubator.  See the class BoxFiller.  I'm
working on a better version of it with an icon and so on, but it's very easy to
use, and you can design some very nice GUIs with it.  I basically wrapped
javax.swing.Box.Filler as a bean which is what Box uses.  Go to
https://jdnc-incubator.dev.java.net/ and see the package wadechandler.  You
might have to get it out of cvs and build it for yourself.  I'll be including it
in a library for NB in the future, but for now you'll have to make the manifest
and jar yourself and add it to NB.
Comment 12 bass 2007-07-16 00:52:20 UTC
Actually, the first thing really necessary to make some progress on this bug
is an option to add GUI components to the palette
directly from *project's JDK*,
so I don't need to link rt.jar as a separate library
just to add javax.swing.Box to the palette.

This would allow me drop Box'es with *custom creation code* right onto the form.

The visual appearance as displayed by the preview would be inconsistent,
but the code generated would be already correct.

BTW, here's the workaround: you can use a component's pre-init/post-init code to drop Box'es before/after the component
in its parent which has a Box layout. The preview would again be incorrect, however.
Comment 13 Tomas Pavek 2007-07-16 08:41:37 UTC
Box in palette plus custom creation code is not enough. The GUI builder needs to be able to create an instance of the 
component to be able to drop it onto the form, no matter you provide your own code for it later. Box is not a JavaBean.

But Box itself as an instabce is not very useful. What we talk about here is the Box.Filler class, which is not a bean 
either - it is created and customized by using the various static methods of the Box class.
Comment 14 MackSix 2011-10-10 01:37:19 UTC
Isn't this already resolved? I can add Swing Fillers to BoxLayout.
Comment 15 Jan Stola 2011-10-11 13:13:27 UTC
(In reply to comment #14)
> Isn't this already resolved? I can add Swing Fillers to BoxLayout.

Yes, you are right. We have support for Box.Filler class since NetBeans 7.0. Thanks for pointing this out.