title: Changing layout and preferred size in Swing unicenta opos
body: <p>How to change layout manager and how to make any component free to resize without any reference in changing other component?</p>
  
  <p>I am work on unicenta 3.7 source code to modify the <code>JPanel</code> <code>Ticket</code>, but when I change the preferred size from properties, it's kind of something dynamic return the original preferred  size generated code, so: </p>
  
  <p><strong>my question is how as eg , how to chage layout manager and how to make any component free to resize without any reference in changing other component , i feel like there are a magnetic force between components in the image above, that when you move Jtext field the buttons affected by it</strong> </p>
  
  <p>Here is the image of <code>Ticket</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/IPvRD.png" alt="enter image description here"></p>
  
  <p>And here is the source code panel <code>Ticket.form</code></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"&gt;
    &lt;Properties&gt;
      &lt;Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"&gt;
        &lt;Color blue="99" green="cc" red="ff" type="rgb"/&gt;
      &lt;/Property&gt;
    &lt;/Properties&gt;
    &lt;AuxValues&gt;
      &lt;AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/&gt;
      &lt;AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/&gt;
      &lt;AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/&gt;
      &lt;AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/&gt;
      &lt;AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/&gt;
      &lt;AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/&gt;
      &lt;AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/&gt;
      &lt;AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/&gt;
      &lt;AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/&gt;
      &lt;AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-24,0,0,3,17"/&gt;
    &lt;/AuxValues&gt;
  
    &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/&gt;
    &lt;SubComponents&gt;
      &lt;Container class="javax.swing.JPanel" name="m_jPanContainer"&gt;
        &lt;Constraints&gt;
          &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"&gt;
            &lt;CardConstraints cardName="ticket"/&gt;
          &lt;/Constraint&gt;
        &lt;/Constraints&gt;
  
        &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/&gt;
        &lt;SubComponents&gt;
          &lt;Container class="javax.swing.JPanel" name="m_jOptions"&gt;
            &lt;Constraints&gt;
              &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"&gt;
                &lt;BorderConstraints direction="North"/&gt;
              &lt;/Constraint&gt;
            &lt;/Constraints&gt;
  
            &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/&gt;
            &lt;SubComponents&gt;
              &lt;Container class="javax.swing.JPanel" name="m_jButtons"&gt;
                &lt;Constraints&gt;
                  &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"&gt;
                    &lt;BorderConstraints direction="Before"/&gt;
                  &lt;/Constraint&gt;
                &lt;/Constraints&gt;
  
                &lt;Layout&gt;
                  &lt;DimensionLayout dim="0"&gt;
                    &lt;Group type="103" groupAlignment="0" attributes="0"&gt;
                        &lt;Group type="102" alignment="0" attributes="0"&gt;
                            &lt;EmptySpace min="5" pref="5" max="-2" attributes="0"/&gt;
                            &lt;Component id="jButton1" min="-2" max="-2" attributes="0"/&gt;
                            &lt;EmptySpace max="32767" attributes="0"/&gt;
                            &lt;Component id="btnCustomer" min="-2" max="-2" attributes="0"/&gt;
                            &lt;EmptySpace max="32767" attributes="0"/&gt;
                            &lt;Component id="btnSplit" min="-2" max="-2" attributes="0"/&gt;
                            &lt;EmptySpace max="32767" attributes="0"/&gt;
                        &lt;/Group&gt;
                    &lt;/Group&gt;
                  &lt;/DimensionLayout&gt;
                  &lt;DimensionLayout dim="1"&gt;
                    &lt;Group type="103" groupAlignment="0" attributes="0"&gt;
                        &lt;Group type="102" attributes="0"&gt;
                            &lt;EmptySpace min="5" pref="5" max="-2" attributes="0"/&gt;
                            &lt;Group type="103" groupAlignment="0" attributes="0"&gt;
                                &lt;Component id="jButton1" min="-2" max="-2" attributes="0"/&gt;
                                &lt;Component id="btnCustomer" min="-2" max="-2" attributes="0"/&gt;
                                &lt;Component id="btnSplit" min="-2" max="-2" attributes="0"/&gt;
                            &lt;/Group&gt;
                            &lt;EmptySpace min="-2" pref="5" max="-2" attributes="0"/&gt;
                        &lt;/Group&gt;
                    &lt;/Group&gt;
                  &lt;/DimensionLayout&gt;
                &lt;/Layout&gt;
                &lt;SubComponents&gt;
                  &lt;Component class="javax.swing.JButton" name="jButton1"&gt;
                    &lt;Properties&gt;
                      &lt;Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"&gt;
                        &lt;Image iconType="3" name="/com/openbravo/images/customer_add_sml.png"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="toolTipText" type="java.lang.String" value="Add New Customer"/&gt;
                      &lt;Property name="focusPainted" type="boolean" value="false"/&gt;
                      &lt;Property name="focusable" type="boolean" value="false"/&gt;
                      &lt;Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"&gt;
                        &lt;Insets value="[0, 4, 0, 4]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="requestFocusEnabled" type="boolean" value="false"/&gt;
                    &lt;/Properties&gt;
                    &lt;Events&gt;
                      &lt;EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/&gt;
                    &lt;/Events&gt;
                  &lt;/Component&gt;
                  &lt;Component class="javax.swing.JButton" name="btnCustomer"&gt;
                    &lt;Properties&gt;
                      &lt;Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"&gt;
                        &lt;Image iconType="3" name="/com/openbravo/images/customer_sml.png"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="toolTipText" type="java.lang.String" value="Show Customers"/&gt;
                      &lt;Property name="focusPainted" type="boolean" value="false"/&gt;
                      &lt;Property name="focusable" type="boolean" value="false"/&gt;
                      &lt;Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"&gt;
                        &lt;Insets value="[0, 4, 0, 4]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="requestFocusEnabled" type="boolean" value="false"/&gt;
                    &lt;/Properties&gt;
                    &lt;Events&gt;
                      &lt;EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCustomerActionPerformed"/&gt;
                    &lt;/Events&gt;
                  &lt;/Component&gt;
                  &lt;Component class="javax.swing.JButton" name="btnSplit"&gt;
                    &lt;Properties&gt;
                      &lt;Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"&gt;
                        &lt;Image iconType="3" name="/com/openbravo/images/sale_split_sml.png"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="toolTipText" type="java.lang.String" value="Split Sale"/&gt;
                      &lt;Property name="focusPainted" type="boolean" value="false"/&gt;
                      &lt;Property name="focusable" type="boolean" value="false"/&gt;
                      &lt;Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"&gt;
                        &lt;Insets value="[0, 4, 0, 4]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                        &lt;Dimension value="[50, 40]"/&gt;
                      &lt;/Property&gt;
                      &lt;Property name="requestFocusEnabled" type="boolean" value="false"/&gt;
                    &lt;/Properties&gt;
                    &lt;Events&gt;
                      &lt;EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSplitActionPerformed"/&gt;
                    &lt;/Events&gt;
                  &lt;/Component&gt;
                &lt;/SubComponents&gt;
              &lt;/Container&gt;
              &lt;Container class="javax.swing.JPanel" name="m_jPanelScripts"&gt;
                &lt;Constraints&gt;
                  &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"&gt;
                    &lt;BorderConstraints direction="After"/&gt;
                  &lt;/Constraint&gt;
                &lt;/Constraints&gt;
  
                &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/&gt;
                &lt;SubComponents&gt;
                  &lt;Container class="javax.swing.JPanel" name="m_jButtonsExt"&gt;
                    &lt;Constraints&gt;
                      &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"&gt;
                        &lt;BorderConstraints direction="After"/&gt;
                      &lt;/Constraint&gt;
                    &lt;/Constraints&gt;
  
                    &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/&gt;
                    &lt;SubComponents&gt;
                      &lt;Container class="javax.swing.JPanel" name="jPanel1"&gt;
                        &lt;Properties&gt;
                          &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                            &lt;Dimension value="[235, 50]"/&gt;
                          &lt;/Property&gt;
                        &lt;/Properties&gt;
  
                        &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/&gt;
                        &lt;SubComponents&gt;
                          &lt;Component class="javax.swing.JButton" name="m_jbtnScale"&gt;
                            &lt;Properties&gt;
                              &lt;Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"&gt;
                                &lt;Font name="Arial" size="11" style="0"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"&gt;
                                &lt;Image iconType="3" name="/com/openbravo/images/scale.png"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"&gt;
                                &lt;ResourceString bundle="pos_messages.properties" key="button.scale" replaceFormat="AppLocal.getIntString(&amp;quot;{key}&amp;quot;)"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="toolTipText" type="java.lang.String" value="Scale"/&gt;
                              &lt;Property name="focusPainted" type="boolean" value="false"/&gt;
                              &lt;Property name="focusable" type="boolean" value="false"/&gt;
                              &lt;Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"&gt;
                                &lt;Insets value="[8, 14, 8, 14]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[85, 44]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[85, 44]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[85, 40]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="requestFocusEnabled" type="boolean" value="false"/&gt;
                            &lt;/Properties&gt;
                            &lt;Events&gt;
                              &lt;EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnScaleActionPerformed"/&gt;
                            &lt;/Events&gt;
                          &lt;/Component&gt;
                          &lt;Component class="javax.swing.JButton" name="jbtnMooring"&gt;
                            &lt;Properties&gt;
                              &lt;Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"&gt;
                                &lt;Font name="Arial" size="11" style="0"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"&gt;
                                &lt;ResourceString bundle="pos_messages.properties" key="button.moorings" replaceFormat="java.util.ResourceBundle.getBundle(&amp;quot;{bundleNameSlashes}&amp;quot;).getString(&amp;quot;{key}&amp;quot;)"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"&gt;
                                &lt;Insets value="[8, 14, 8, 14]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[80, 40]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[80, 40]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[80, 40]"/&gt;
                              &lt;/Property&gt;
                            &lt;/Properties&gt;
                            &lt;Events&gt;
                              &lt;EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnMooringActionPerformed"/&gt;
                            &lt;/Events&gt;
                          &lt;/Component&gt;
                          &lt;Component class="javax.swing.JButton" name="j_btnKitchenPrt"&gt;
                            &lt;Properties&gt;
                              &lt;Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"&gt;
                                &lt;Image iconType="3" name="/com/openbravo/images/printer24.png"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"&gt;
                                &lt;ResourceString bundle="pos_messages.properties" key="button.sendorder" replaceFormat="java.util.ResourceBundle.getBundle(&amp;quot;{bundleNameSlashes}&amp;quot;).getString(&amp;quot;{key}&amp;quot;)"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="toolTipText" type="java.lang.String" value="Send to Kichen Printer"/&gt;
                              &lt;Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"&gt;
                                &lt;Insets value="[0, 4, 0, 4]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[50, 40]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[50, 40]"/&gt;
                              &lt;/Property&gt;
                              &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                                &lt;Dimension value="[50, 40]"/&gt;
                              &lt;/Property&gt;
                            &lt;/Properties&gt;
                            &lt;Events&gt;
                              &lt;EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="j_btnKitchenPrtActionPerformed"/&gt;
                            &lt;/Events&gt;
                          &lt;/Component&gt;
                        &lt;/SubComponents&gt;
                      &lt;/Container&gt;
                    &lt;/SubComponents&gt;
                  &lt;/Container&gt;
                &lt;/SubComponents&gt;
              &lt;/Container&gt;
              &lt;Container class="javax.swing.JPanel" name="m_jPanelBag"&gt;
                &lt;Properties&gt;
                  &lt;Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"&gt;
                    &lt;Dimension value="[0, 50]"/&gt;
                  &lt;/Property&gt;
                &lt;/Properties&gt;
                &lt;Constraints&gt;
                  &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"&gt;
                    &lt;BorderConstraints direction="Center"/&gt;
                  &lt;/Constraint&gt;
                &lt;/Constraints&gt;
  
                &lt;Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/&gt;
              &lt;/Container&gt;
            &lt;/SubComponents&gt;
          &lt;/Container&gt;
          &lt;Container class="javax.swing.JPanel" name="m_jPanTicket"&gt;
            &lt;Properties&gt;
              &lt;Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"&gt;
                &lt;Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"&gt;
                  &lt;EmptyBorder bottom="5" left="5" right="5" top="5"/&gt;
                &lt;/Border&gt;
              &lt;/Property&gt;
            &lt;/Properties&gt;
            &lt;Constraints&gt;
              &lt;Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"&gt;
                &lt;BorderConstraints direction="Center"/&gt;
              &lt;/Constraint&gt;
            &lt;/Constraints&gt;
  </code></pre>