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 222271

Summary: Generated code throws IllegalArgumentException
Product: guibuilder Reporter: nb_johan1
Component: CodeAssignee: issues@guibuilder <issues>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description nb_johan1 2012-11-16 13:18:42 UTC
Netbeans generated the following code:

       itemsGroupPanelLayout.setHorizontalGroup(        itemsGroupPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, itemsGroupPanelLayout.createSequentialGroup()
                        .addComponent(catItemsButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(searchItemSep, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(searchItemTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(catItemsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 858, Short.MAX_VALUE))
                .addComponent(searchItemBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE))

However it seems that the .addGap on the last line does not accept the passed parameters, because it ends up calling this method:

GroupLayout.checkResizeType(int type, boolean isComponentSpring)

with params (-1, false), which throws IllegalArgumentException.
(if isComponentString=false type should be -2.)

I use jdk1.6.0_24

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid size
	at javax.swing.GroupLayout.checkResizeType(
	at javax.swing.GroupLayout.checkSize(
	at javax.swing.GroupLayout.access$500(
	at javax.swing.GroupLayout$GapSpring.<init>(
	at javax.swing.GroupLayout$Group.addGap(
	at javax.swing.GroupLayout$SequentialGroup.addGap(
Comment 1 Tomas Pavek 2012-11-16 15:37:55 UTC
The last gap in this case should be generated as addContainerGap(), just like at the beginning.

Did the GUI form in the designer built fine? I.e. you did not get the same exception from NetBeans itself, only when running the generated code?

Do you still have the form that generates the code like this? I'm have no luck to simulate the situation myself. Could you provide the entire form, i.e. mainly the .form file? Either attach it here, or send directly to me (to keep it private). Thanks.
Comment 2 nb_johan1 2012-11-16 18:41:17 UTC
Yes when I had the problem I could preview the GUI in the editor.
The thing is that now it works. I'm not sure what I did, but for sure I've executed the clean target, which I did not do previously.