Search in sources :

Example 21 with CellConstraints

use of com.jgoodies.forms.layout.CellConstraints in project SIMRacingApps by SIMRacingApps.

the class SingleInstanceForm method addFillComponents.

/**
    * Adds fill components to empty cells in the first row and first column of the grid.
    * This ensures that the grid spacing will be the same as shown in the designer.
    * @param cols an array of column indices in the first row where fill components should be added.
    * @param rows an array of row indices in the first column where fill components should be added.
    */
void addFillComponents(Container panel, int[] cols, int[] rows) {
    Dimension filler = new Dimension(10, 10);
    boolean filled_cell_11 = false;
    CellConstraints cc = new CellConstraints();
    if (cols.length > 0 && rows.length > 0) {
        if (cols[0] == 1 && rows[0] == 1) {
            /** add a rigid area  */
            panel.add(Box.createRigidArea(filler), cc.xy(1, 1));
            filled_cell_11 = true;
        }
    }
    for (int index = 0; index < cols.length; index++) {
        if (cols[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1));
    }
    for (int index = 0; index < rows.length; index++) {
        if (rows[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index]));
    }
}
Also used : Dimension(java.awt.Dimension) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 22 with CellConstraints

use of com.jgoodies.forms.layout.CellConstraints in project SIMRacingApps by SIMRacingApps.

the class ConfigForm method addFillComponents.

/**
    * Adds fill components to empty cells in the first row and first column of the grid.
    * This ensures that the grid spacing will be the same as shown in the designer.
    * @param cols an array of column indices in the first row where fill components should be added.
    * @param rows an array of row indices in the first column where fill components should be added.
    */
void addFillComponents(Container panel, int[] cols, int[] rows) {
    Dimension filler = new Dimension(10, 10);
    boolean filled_cell_11 = false;
    CellConstraints cc = new CellConstraints();
    if (cols.length > 0 && rows.length > 0) {
        if (cols[0] == 1 && rows[0] == 1) {
            /** add a rigid area  */
            panel.add(Box.createRigidArea(filler), cc.xy(1, 1));
            filled_cell_11 = true;
        }
    }
    for (int index = 0; index < cols.length; index++) {
        if (cols[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1));
    }
    for (int index = 0; index < rows.length; index++) {
        if (rows[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index]));
    }
}
Also used : Dimension(java.awt.Dimension) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 23 with CellConstraints

use of com.jgoodies.forms.layout.CellConstraints in project SIMRacingApps by SIMRacingApps.

the class ConfigForm method createPanel.

public JPanel createPanel() {
    JPanel jpanel1 = new JPanel();
    FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:7DLU:NONE", "CENTER:3DLU:NONE,FILL:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE");
    CellConstraints cc = new CellConstraints();
    jpanel1.setLayout(formlayout1);
    _logTextArea.setName("logTextArea");
    JScrollPane jscrollpane1 = new JScrollPane();
    jscrollpane1.setViewportView(_logTextArea);
    jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jpanel1.add(jscrollpane1, cc.xy(2, 6));
    _logSeparator.setName("logSeparator");
    _logSeparator.setText(Messages.getString("log"));
    jpanel1.add(_logSeparator, cc.xy(2, 4));
    _tab.setName("tab");
    jpanel1.add(_tab, cc.xywh(1, 2, 3, 1));
    addFillComponents(jpanel1, new int[] { 1, 2, 3 }, new int[] { 1, 3, 4, 5, 6, 7 });
    return jpanel1;
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 24 with CellConstraints

use of com.jgoodies.forms.layout.CellConstraints in project SIMRacingApps by SIMRacingApps.

the class VersionInfoForm method addFillComponents.

/**
    * Adds fill components to empty cells in the first row and first column of the grid.
    * This ensures that the grid spacing will be the same as shown in the designer.
    * @param cols an array of column indices in the first row where fill components should be added.
    * @param rows an array of row indices in the first column where fill components should be added.
    */
void addFillComponents(Container panel, int[] cols, int[] rows) {
    Dimension filler = new Dimension(10, 10);
    boolean filled_cell_11 = false;
    CellConstraints cc = new CellConstraints();
    if (cols.length > 0 && rows.length > 0) {
        if (cols[0] == 1 && rows[0] == 1) {
            /** add a rigid area  */
            panel.add(Box.createRigidArea(filler), cc.xy(1, 1));
            filled_cell_11 = true;
        }
    }
    for (int index = 0; index < cols.length; index++) {
        if (cols[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1));
    }
    for (int index = 0; index < rows.length; index++) {
        if (rows[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index]));
    }
}
Also used : Dimension(java.awt.Dimension) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 25 with CellConstraints

use of com.jgoodies.forms.layout.CellConstraints in project intellij-community by JetBrains.

the class FormLayoutSourceGenerator method generateComponentLayout.

public void generateComponentLayout(final LwComponent component, final FormSourceCodeGenerator generator, final String variable, final String parentVariable) {
    if (!myHaveCc) {
        generator.append("com.jgoodies.forms.layout.CellConstraints cc = new com.jgoodies.forms.layout.CellConstraints();\n");
        myHaveCc = true;
    }
    generator.startMethodCall(parentVariable, "add");
    generator.pushVar(variable);
    CellConstraints cc = (CellConstraints) component.getCustomLayoutConstraints();
    GridConstraints constraints = component.getConstraints();
    final boolean haveInsets = !cc.insets.equals(new Insets(0, 0, 0, 0));
    if (haveInsets) {
        generator.startConstructor(CellConstraints.class.getName());
    } else {
        if (constraints.getColSpan() == 1 && constraints.getRowSpan() == 1) {
            generator.startMethodCall("cc", "xy");
        } else if (constraints.getRowSpan() == 1) {
            generator.startMethodCall("cc", "xyw");
        } else {
            generator.startMethodCall("cc", "xywh");
        }
    }
    generator.push(constraints.getColumn() + 1);
    generator.push(constraints.getRow() + 1);
    if (constraints.getColSpan() > 1 || constraints.getRowSpan() > 1 || haveInsets) {
        generator.push(constraints.getColSpan());
    }
    if (constraints.getRowSpan() > 1 || haveInsets) {
        generator.push(constraints.getRowSpan());
    }
    if (cc.hAlign != CellConstraints.DEFAULT || cc.vAlign != CellConstraints.DEFAULT || haveInsets) {
        @NonNls String hAlign = (cc.hAlign == CellConstraints.DEFAULT) ? "DEFAULT" : FormLayoutCodeGenerator.HORZ_ALIGN_FIELDS[Utils.alignFromConstraints(constraints, true)];
        @NonNls String vAlign = (cc.vAlign == CellConstraints.DEFAULT) ? "DEFAULT" : FormLayoutCodeGenerator.VERT_ALIGN_FIELDS[Utils.alignFromConstraints(constraints, false)];
        generator.pushVar("com.jgoodies.forms.layout.CellConstraints." + hAlign);
        generator.pushVar("com.jgoodies.forms.layout.CellConstraints." + vAlign);
    }
    if (haveInsets) {
        generator.newInsets(cc.insets);
    }
    generator.endMethod();
    generator.endMethod();
}
Also used : NonNls(org.jetbrains.annotations.NonNls) Insets(java.awt.Insets) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Aggregations

CellConstraints (com.jgoodies.forms.layout.CellConstraints)126 FormLayout (com.jgoodies.forms.layout.FormLayout)81 JPanel (javax.swing.JPanel)60 Dimension (java.awt.Dimension)41 JLabel (javax.swing.JLabel)29 JScrollPane (javax.swing.JScrollPane)26 TitledSeparator (com.jeta.forms.components.separator.TitledSeparator)6 DatePanel (jgnash.ui.components.DatePanel)5 JRadioButton (javax.swing.JRadioButton)4 JSpinner (javax.swing.JSpinner)4 SpinnerNumberModel (javax.swing.SpinnerNumberModel)4 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)3 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 TextFieldWithBrowseButton (com.intellij.openapi.ui.TextFieldWithBrowseButton)2 PanelBuilder (com.jgoodies.forms.builder.PanelBuilder)2 ResourceBundle (java.util.ResourceBundle)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 UserActivityListener (com.intellij.ui.UserActivityListener)1