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 154955 - LAYOUT: Changes of values in "Space Around Component" have no effect
Summary: LAYOUT: Changes of values in "Space Around Component" have no effect
Status: VERIFIED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Natural Layout (show other bugs)
Version: 6.x
Hardware: PC All
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks: 136425
  Show dependency tree
 
Reported: 2008-12-08 17:00 UTC by Marian Petras
Modified: 2011-10-04 13:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
154955.wmv (1.37 MB, application/octet-stream)
2008-12-16 13:05 UTC, Jiri Vagner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Petras 2008-12-08 17:00:01 UTC
I am trying to make a very simple form using the Swing layout. It should be a JPanel with a JLabel and a JTextField
inside. There should be a default space between the label and the text-field but there should be no space left and right
of these components.

    +-----------------------------------------+
    |Name:                                    |
    |                                         |
    ++---------------------------------------+|
    || (empty text-field)                    ||
    |+---------------------------------------+|
    +-----------------------------------------+

What I do:
 1) create a new JPanel form
 2) put a JLabel into it, to the upper left corner (no space above it or left of it)
 3) set the text of the label
 4) place the text-field below the "Name:" label, with the default space between
 5) set the "columns" property of the text-field to 15
 6) restore the default value of the "text" property of the text-field
 7) right-click on the panel and select "Set Default Size"
 
    The panel shrinks but there is an extra space right of and below the text-field.
    So what I do:
 
 8) right-click on the text-field and select "Space Around Component..."

    In the "Space Around Component" dialogue, I open the "Right" combo-box.
    I see the following values:

        Left:   No Space
        Right:  Default
        Top:    Default Small
        Bottom: Default

 9) open the "Right" combo-box

    I would like to select value "No Space" but there is no such item in the menu. (!)

10) enter value "0" for "Right" and "Bottom"
11) press OK to close the "Space Around Component" dialogue

    I see no change in the form. (!)

12) open the "Space Around Component" dialogue again

    The values are unchanged, i.e. "Default" for both "Right" and "Bottom".

It seems that changes of values in the combo-box have no effect - they are not applied when the user presses the OK button.
Comment 1 Jiri Vagner 2008-12-16 13:04:04 UTC
Reproducible. There is no ui response to "0" values and combobox item "No Space" is not available.

Workaround: You were trying to set following values using "Space Around Component..." dialog 

        Left:   No Space
        Right:  Default
        Top:    Default Small
        Bottom: Default

So, it is very easy to set just via mouse using only designer, watch the attached video.
Comment 2 Jiri Vagner 2008-12-16 13:05:54 UTC
Created attachment 75023 [details]
154955.wmv
Comment 3 Marian Petras 2010-08-10 21:33:13 UTC
OK, the workaround works (in this case).

Just one more complaint: Please do not generate the code that specifies the size of space right of the label.

In the example, the code generated is something like:

                layout.setHorizontalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addContainerGap(36, Short.MAX_VALUE))
                        .addComponent(jTextField1)
                );

The line ".addContainerGap(36, Short.MAX_VALUE))" is the evil. The size of the container gap is explicitly specified in the generated source code, although:
    - it is superfluous and causes just troubles
    - it is hard-coded and the hard-coded value depends on L&F and its settings at the moment the form was being designed
    - the user has never requested/specified it
    - the user cannot remove it
    - the user cannot change it

Also note that the value is updated according to the current developer's L&F every time the form is opened and modified in any way. This causes unnecessary mess in patches and diff views.

Solution: Just do not generate it. Omit it. It needn't be there.
Comment 4 asenk 2011-10-04 13:06:30 UTC
Fixed in 7.1 Free Design improvements
Comment 5 asenk 2011-10-04 13:07:12 UTC
Verified

Product Version: NetBeans IDE Dev (Build 201110030601)
Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17
System: Linux version 2.6.38-11-generic running on i386; UTF-8; en_US (nb)