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 203913 - Lost Space Resizing Capability Between Component & Right Side Of Frame
Summary: Lost Space Resizing Capability Between Component & Right Side Of Frame
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Natural Layout (show other bugs)
Version: 7.1
Hardware: All All
: P2 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-18 15:17 UTC by MackSix
Modified: 2011-11-03 15:39 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Project that exhibits the error. (26.64 KB, application/zip)
2011-10-18 23:12 UTC, MackSix
Details
Screenshot of action. (201.61 KB, image/png)
2011-11-01 04:29 UTC, MackSix
Details
Project that exhibits the error. (25.01 KB, application/zip)
2011-11-01 10:41 UTC, MackSix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description MackSix 2011-10-18 15:17:04 UTC
If Previewing a JFrame form with a Component that is anchored to the right side of the JFrame and the space to the right is set to Resizable, the space does not resize if viewed with "Preview Design" button on designer toolbar. 

It resizes ok if the project is run (or file is run) from the Project window.

This worked in v7.0.1, but now it doesn't. 

Product Version: NetBeans IDE Dev (Build 201110171706)
Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
Comment 1 MackSix 2011-10-18 23:12:09 UTC
Created attachment 112200 [details]
Project that exhibits the error.

1) Open up this project and open up NewJFrame.java in editor.
2) Put in design mode and then click Preview Design.
3) Resize Frame and notice that panel resizes and the space on the left of the panel resizes, but the space on the right does not.
4) Stop the preview.
5) Right click NewJFrame.java in Project Window and choose "Run File".
6) Notice that the right side space now resized as frame is resized.
7) Right click the project and choose "Run" and notice the right side space resizes as teh frame is resized.
Comment 2 Jan Stola 2011-10-27 11:57:25 UTC
Thank you for a reproducible test-case. I was able to reproduce the problem using the attached project and the described steps.
Comment 3 MackSix 2011-11-01 04:28:13 UTC
Actually, this is generating different code than v7.0.1 and now it behaves incorrectly the same in preview and if I run the project or jar.

See attached screenshot. The left file is built fresh in the dev version and the right file is built fresh on v7.0.1 and works correctly.

Product Version: NetBeans IDE Dev (Build 201110300600)
Java: 1.7.0_01; Java HotSpot(TM) Client VM 21.1-b02
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
Comment 4 MackSix 2011-11-01 04:29:07 UTC
Created attachment 112634 [details]
Screenshot of action.
Comment 5 MackSix 2011-11-01 04:32:28 UTC
I think this is P2 now.
Comment 6 MackSix 2011-11-01 04:50:08 UTC
@@ -47,10 +51,10 @@
         getContentPane().setLayout(layout);
         layout.setHorizontalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(layout.createSequentialGroup()
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                 .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addContainerGap())
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
         layout.setVerticalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Comment 7 Jan Stola 2011-11-01 10:09:29 UTC
I am sorry, but I am confused by your additional comments. I don't see how are they related to the original problem of this issue = different behaviour of the attached form during design-time versus run-time.

The attached form is on neither side of the mentioned diff.

> Actually, this is generating different code than v7.0.1 and now it behaves
> incorrectly the same in preview and if I run the project or jar.

As I already mentioned, this issue is about discrepancy between preview and run-time. You are confirming here that this is not the case for your new form.

> See attached screenshot. The left file is built fresh in the dev version and
> the right file is built fresh on v7.0.1 and works correctly.

Could you, please, clarify the problem (actual versus expected behaviour). The diff just shows a difference between two different forms (that, of course, behave in a different way). Why do you think that one of them is correct and one of them is incorrect?
Comment 8 MackSix 2011-11-01 10:23:15 UTC
They were constructed the same way in 2 versions with the spacing on the top, bottom, right, and left set to re-size and they produced different code that produce different behaviors. The right space between the panel and the frame does not re-size on the form made in the indicated dev version but it produces a re-sizable right space in v7.0.1.

In short, it is impossible to produce the form with a re-sizable right space in the latest dev version indicated, it won't re-size when the frame is re-sized.
Comment 9 MackSix 2011-11-01 10:41:30 UTC
Created attachment 112648 [details]
Project that exhibits the error.

This has all 4 spaces around the JPanel set to resizable, but the right side space does not resize when the JFrame is resized. This occurs when Project is run from NetBeans or from Jar.
Comment 10 Jan Stola 2011-11-01 14:23:25 UTC
Thank you for additional information. Surprisingly, both mentioned problems

* discrepancy between preview and run-time
* impossibility to create a resizing gap on the right/bottom side of component

really seem to have the same root. The layout model contains correct information about the resizable gap. Unfortunately, both SwingLayoutCodeGenerator (responsible for code generation) and SwingLayoutBuilder (responsible for preview) contain some suspicious code that generates non-resizable gap instead.

The source code of the first test-case is correct since it was generated in some older build of NetBeans, i.e, this bug manifests itself in preview only until the code is regenerated.

> I think this is P2 now.

I agree.
Comment 11 Tomas Pavek 2011-11-01 17:50:14 UTC
I've made the suspicious code even more suspicious, hoping it fixes this case.
http://hg.netbeans.org/jet-main/rev/7fb120fb8e0a
Comment 12 Quality Engineering 2011-11-02 15:17:01 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/7fb120fb8e0a
User: Tomas Pavek <tpavek@netbeans.org>
Log: #203913 better detection of the case where GroupLayout can't handle resizing default container gap
Comment 13 Quality Engineering 2011-11-03 15:39:49 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/7fb120fb8e0a
User: Tomas Pavek <tpavek@netbeans.org>
Log: #203913 better detection of the case where GroupLayout can't handle resizing default container gap