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.
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.
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.
Created attachment 75023 [details] 154955.wmv
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.
Fixed in 7.1 Free Design improvements
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)