-1

How to change layout manager and how to make any component free to resize without any reference in changing other component?

I am work on unicenta 3.7 source code to modify the JPanel Ticket, but when I change the preferred size from properties, it's kind of something dynamic return the original preferred size generated code, so:

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

Here is the image of Ticket:

enter image description here

And here is the source code panel Ticket.form

<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
  <Properties>
    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
      <Color blue="99" green="cc" red="ff" type="rgb"/>
    </Property>
  </Properties>
  <AuxValues>
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
    <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"/>
  </AuxValues>

  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
  <SubComponents>
    <Container class="javax.swing.JPanel" name="m_jPanContainer">
      <Constraints>
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
          <CardConstraints cardName="ticket"/>
        </Constraint>
      </Constraints>

      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
      <SubComponents>
        <Container class="javax.swing.JPanel" name="m_jOptions">
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="North"/>
            </Constraint>
          </Constraints>

          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
          <SubComponents>
            <Container class="javax.swing.JPanel" name="m_jButtons">
              <Constraints>
                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                  <BorderConstraints direction="Before"/>
                </Constraint>
              </Constraints>

              <Layout>
                <DimensionLayout dim="0">
                  <Group type="103" groupAlignment="0" attributes="0">
                      <Group type="102" alignment="0" attributes="0">
                          <EmptySpace min="5" pref="5" max="-2" attributes="0"/>
                          <Component id="jButton1" min="-2" max="-2" attributes="0"/>
                          <EmptySpace max="32767" attributes="0"/>
                          <Component id="btnCustomer" min="-2" max="-2" attributes="0"/>
                          <EmptySpace max="32767" attributes="0"/>
                          <Component id="btnSplit" min="-2" max="-2" attributes="0"/>
                          <EmptySpace max="32767" attributes="0"/>
                      </Group>
                  </Group>
                </DimensionLayout>
                <DimensionLayout dim="1">
                  <Group type="103" groupAlignment="0" attributes="0">
                      <Group type="102" attributes="0">
                          <EmptySpace min="5" pref="5" max="-2" attributes="0"/>
                          <Group type="103" groupAlignment="0" attributes="0">
                              <Component id="jButton1" min="-2" max="-2" attributes="0"/>
                              <Component id="btnCustomer" min="-2" max="-2" attributes="0"/>
                              <Component id="btnSplit" min="-2" max="-2" attributes="0"/>
                          </Group>
                          <EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
                      </Group>
                  </Group>
                </DimensionLayout>
              </Layout>
              <SubComponents>
                <Component class="javax.swing.JButton" name="jButton1">
                  <Properties>
                    <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
                      <Image iconType="3" name="/com/openbravo/images/customer_add_sml.png"/>
                    </Property>
                    <Property name="toolTipText" type="java.lang.String" value="Add New Customer"/>
                    <Property name="focusPainted" type="boolean" value="false"/>
                    <Property name="focusable" type="boolean" value="false"/>
                    <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
                      <Insets value="[0, 4, 0, 4]"/>
                    </Property>
                    <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="requestFocusEnabled" type="boolean" value="false"/>
                  </Properties>
                  <Events>
                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
                  </Events>
                </Component>
                <Component class="javax.swing.JButton" name="btnCustomer">
                  <Properties>
                    <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
                      <Image iconType="3" name="/com/openbravo/images/customer_sml.png"/>
                    </Property>
                    <Property name="toolTipText" type="java.lang.String" value="Show Customers"/>
                    <Property name="focusPainted" type="boolean" value="false"/>
                    <Property name="focusable" type="boolean" value="false"/>
                    <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
                      <Insets value="[0, 4, 0, 4]"/>
                    </Property>
                    <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="requestFocusEnabled" type="boolean" value="false"/>
                  </Properties>
                  <Events>
                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCustomerActionPerformed"/>
                  </Events>
                </Component>
                <Component class="javax.swing.JButton" name="btnSplit">
                  <Properties>
                    <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
                      <Image iconType="3" name="/com/openbravo/images/sale_split_sml.png"/>
                    </Property>
                    <Property name="toolTipText" type="java.lang.String" value="Split Sale"/>
                    <Property name="focusPainted" type="boolean" value="false"/>
                    <Property name="focusable" type="boolean" value="false"/>
                    <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
                      <Insets value="[0, 4, 0, 4]"/>
                    </Property>
                    <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                      <Dimension value="[50, 40]"/>
                    </Property>
                    <Property name="requestFocusEnabled" type="boolean" value="false"/>
                  </Properties>
                  <Events>
                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSplitActionPerformed"/>
                  </Events>
                </Component>
              </SubComponents>
            </Container>
            <Container class="javax.swing.JPanel" name="m_jPanelScripts">
              <Constraints>
                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                  <BorderConstraints direction="After"/>
                </Constraint>
              </Constraints>

              <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
              <SubComponents>
                <Container class="javax.swing.JPanel" name="m_jButtonsExt">
                  <Constraints>
                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                      <BorderConstraints direction="After"/>
                    </Constraint>
                  </Constraints>

                  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
                  <SubComponents>
                    <Container class="javax.swing.JPanel" name="jPanel1">
                      <Properties>
                        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                          <Dimension value="[235, 50]"/>
                        </Property>
                      </Properties>

                      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
                      <SubComponents>
                        <Component class="javax.swing.JButton" name="m_jbtnScale">
                          <Properties>
                            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
                              <Font name="Arial" size="11" style="0"/>
                            </Property>
                            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
                              <Image iconType="3" name="/com/openbravo/images/scale.png"/>
                            </Property>
                            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                              <ResourceString bundle="pos_messages.properties" key="button.scale" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
                            </Property>
                            <Property name="toolTipText" type="java.lang.String" value="Scale"/>
                            <Property name="focusPainted" type="boolean" value="false"/>
                            <Property name="focusable" type="boolean" value="false"/>
                            <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
                              <Insets value="[8, 14, 8, 14]"/>
                            </Property>
                            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[85, 44]"/>
                            </Property>
                            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[85, 44]"/>
                            </Property>
                            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[85, 40]"/>
                            </Property>
                            <Property name="requestFocusEnabled" type="boolean" value="false"/>
                          </Properties>
                          <Events>
                            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnScaleActionPerformed"/>
                          </Events>
                        </Component>
                        <Component class="javax.swing.JButton" name="jbtnMooring">
                          <Properties>
                            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
                              <Font name="Arial" size="11" style="0"/>
                            </Property>
                            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                              <ResourceString bundle="pos_messages.properties" key="button.moorings" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
                            </Property>
                            <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
                              <Insets value="[8, 14, 8, 14]"/>
                            </Property>
                            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[80, 40]"/>
                            </Property>
                            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[80, 40]"/>
                            </Property>
                            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[80, 40]"/>
                            </Property>
                          </Properties>
                          <Events>
                            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnMooringActionPerformed"/>
                          </Events>
                        </Component>
                        <Component class="javax.swing.JButton" name="j_btnKitchenPrt">
                          <Properties>
                            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
                              <Image iconType="3" name="/com/openbravo/images/printer24.png"/>
                            </Property>
                            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                              <ResourceString bundle="pos_messages.properties" key="button.sendorder" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
                            </Property>
                            <Property name="toolTipText" type="java.lang.String" value="Send to Kichen Printer"/>
                            <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
                              <Insets value="[0, 4, 0, 4]"/>
                            </Property>
                            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[50, 40]"/>
                            </Property>
                            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[50, 40]"/>
                            </Property>
                            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                              <Dimension value="[50, 40]"/>
                            </Property>
                          </Properties>
                          <Events>
                            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="j_btnKitchenPrtActionPerformed"/>
                          </Events>
                        </Component>
                      </SubComponents>
                    </Container>
                  </SubComponents>
                </Container>
              </SubComponents>
            </Container>
            <Container class="javax.swing.JPanel" name="m_jPanelBag">
              <Properties>
                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
                  <Dimension value="[0, 50]"/>
                </Property>
              </Properties>
              <Constraints>
                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                  <BorderConstraints direction="Center"/>
                </Constraint>
              </Constraints>

              <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
            </Container>
          </SubComponents>
        </Container>
        <Container class="javax.swing.JPanel" name="m_jPanTicket">
          <Properties>
            <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
              <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
                <EmptyBorder bottom="5" left="5" right="5" top="5"/>
              </Border>
            </Property>
          </Properties>
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="Center"/>
            </Constraint>
          </Constraints>
  • 1) See [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/q/7229226/418556) (Yes.) 2) What is your actual question? – Andrew Thompson Mar 08 '15 at 15:20
  • 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 –  Mar 08 '15 at 16:58
  • That should be part of the main question (I did it for you this time). – Andrew Thompson Mar 08 '15 at 17:02

1 Answers1

-1

you will find a gap between the controls just double click it and make it resizable to be able to move the controls without resize the other controls but instead the gaps will resize

Hatem Badawi
  • 536
  • 4
  • 9