Solved - Strange behaviour in NetBeans 5.5 (and SE 6)

I am using NB 5.5 and I created a new JInternalFrame and choose Free Design then it created the Layout like following (works perfectly this way):

javax.swing.GroupLayout caixaOcorrenciaLayout =new javax.swing.GroupLayout(caixaOcorrencia);

caixaOcorrencia.setLayout(caixaOcorrenciaLayout);

caixaOcorrenciaLayout.setHorizontalGroup(

caixaOcorrenciaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caixaOcorrenciaLayout.createSequentialGroup()

.addGap(12, 12, 12)

.addGroup(caixaOcorrenciaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,false)

.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)

.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING))

.addGap(16, 16, 16)

.addGroup(caixaOcorrenciaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addComponent(cbOcorrencia, javax.swing.GroupLayout.Alignment.LEADING, 0, 461, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.LEADING, caixaOcorrenciaLayout.createSequentialGroup()

.addComponent(campoNumeroNota, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE)

.addComponent(jLabel3)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(campoCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(javax.swing.GroupLayout.Alignment.LEADING, caixaOcorrenciaLayout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(caixaOcorrenciaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(campoTextoLivre, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)

.addGroup(caixaOcorrenciaLayout.createSequentialGroup()

.addComponent(calData, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel5)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(campoHora, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel7)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(cbObservacao, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)))))

.addGap(12, 12, 12))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, caixaOcorrenciaLayout.createSequentialGroup()

.addContainerGap(421, Short.MAX_VALUE)

.addComponent(btnConfirmar, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())

);

But when I added a JPanel to a JTabbedPane (in an old JInternalFrame I had already) and choose Free Design, it created the Layout as following:

org.jdesktop.layout.GroupLayout painelOcorrenciaLayout =new org.jdesktop.layout.GroupLayout(painelOcorrencia);

painelOcorrencia.setLayout(painelOcorrenciaLayout);

painelOcorrenciaLayout.setHorizontalGroup(

painelOcorrenciaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(painelOcorrenciaLayout.createSequentialGroup()

.add(20, 20, 20)

.add(jLabel42, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 300, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

);

I dont want to use JDesktop, I want to use the Swing package, but what can I do since NB does that (the codification) by it self?

Thanks

F.

Message was edited by:

Franzisk

[4626 byte] By [Franziska] at [2007-11-26 17:55:12]
# 1

> I am using NB 5.5 and I created a new JInternalFrame

> and choose Free Design then it created the Layout

> like following (works perfectly this way):

>

> I dont want to use JDesktop, I want to use the Swing

> package, but what can I do since NB does that (the

> codification) by it self?

Don't use Free Design if you don't want to use GroupLayout.

kirillga at 2007-7-9 5:08:19 > top of Java-index,Desktop,Core GUI APIs...
# 2

> I dont want to use JDesktop, I want to use the Swing

> package, but what can I do since NB does that (the

> codification) by it self?

I assume your question is that you don't want to use the org.jdesktop.layout.GroupLayout class, but the new Java6 javax.swing.GroupLayout. To switch between the two, do the following:

1. Open the respective form.

2. In the projects pane, open the sub-items of the form class (the small "+" before the entry).

3. Click on the "Form" element (for example, if you have an "AboutDialog.java", there are the "AboutDialog" and the "Form AboutDialog" elements there.)

4. In the properties of the "Form", switch the "Layout Generation Style" to "Standard Java 6 Code".

This one had me quite a bit; I've had the converse problem, wanting to make an application compatible with Java 5. The thing is, it doesn't change anything for already-generated forms if you change this setting in the global options... and you can't change it manually, as you said, because it's in the generated code.

amayera at 2007-7-9 5:08:19 > top of Java-index,Desktop,Core GUI APIs...