Example usage for com.jgoodies.forms.layout CellConstraints CENTER

List of usage examples for com.jgoodies.forms.layout CellConstraints CENTER

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints CENTER.

Prototype

Alignment CENTER

To view the source code for com.jgoodies.forms.layout CellConstraints CENTER.

Click Source Link

Document

Put the component in the center.

Usage

From source file:org.eclipse.wb.internal.swing.FormLayout.model.SelectionActionsSupport.java

License:Open Source License

@Override
public void addSelectionActions(List<ObjectInfo> objects, List<Object> actions) throws Exception {
    if (objects.isEmpty()) {
        return;//from www.  j ava  2s . c o m
    }
    // prepare constraints
    List<CellConstraintsSupport> constraints = Lists.newArrayList();
    for (ObjectInfo object : objects) {
        // check object
        if (!(object instanceof ComponentInfo) || object.getParent() != m_layout.getContainer()) {
            return;
        }
        // add data info
        ComponentInfo component = (ComponentInfo) object;
        constraints.add(FormLayoutInfo.getConstraints(component));
    }
    // create horizontal actions
    actions.add(new Separator());
    addAlignmentAction(actions, constraints, true, "default.gif",
            ModelMessages.SelectionActionsSupport_haDefault, CellConstraints.DEFAULT);
    addAlignmentAction(actions, constraints, true, "left.gif", ModelMessages.SelectionActionsSupport_haLeft,
            CellConstraints.LEFT);
    addAlignmentAction(actions, constraints, true, "center.gif", ModelMessages.SelectionActionsSupport_haCenter,
            CellConstraints.CENTER);
    addAlignmentAction(actions, constraints, true, "right.gif", ModelMessages.SelectionActionsSupport_haRight,
            CellConstraints.RIGHT);
    addAlignmentAction(actions, constraints, true, "fill.gif", ModelMessages.SelectionActionsSupport_haFill,
            CellConstraints.FILL);
    // create vertical actions
    actions.add(new Separator());
    addAlignmentAction(actions, constraints, false, "default.gif",
            ModelMessages.SelectionActionsSupport_vaDefault, CellConstraints.DEFAULT);
    addAlignmentAction(actions, constraints, false, "top.gif", ModelMessages.SelectionActionsSupport_haTop,
            CellConstraints.TOP);
    addAlignmentAction(actions, constraints, false, "center.gif",
            ModelMessages.SelectionActionsSupport_vaCenter, CellConstraints.CENTER);
    addAlignmentAction(actions, constraints, false, "bottom.gif",
            ModelMessages.SelectionActionsSupport_vaBottom, CellConstraints.BOTTOM);
    addAlignmentAction(actions, constraints, false, "fill.gif", ModelMessages.SelectionActionsSupport_vaFill,
            CellConstraints.FILL);
}

From source file:org.eclipse.wb.tests.designer.swing.model.layout.FormLayout.CellConstraintsSupportTest.java

License:Open Source License

public void test_getSmallAlignmentImage() throws Exception {
    check_getSmallAlignmentImage(CellConstraints.DEFAULT, true, false);
    check_getSmallAlignmentImage(CellConstraints.LEFT, true, true);
    check_getSmallAlignmentImage(CellConstraints.CENTER, true, true);
    check_getSmallAlignmentImage(CellConstraints.RIGHT, true, true);
    check_getSmallAlignmentImage(CellConstraints.FILL, true, true);
    ///*  ww  w  . ja  v a2 s  .  c o  m*/
    check_getSmallAlignmentImage(CellConstraints.DEFAULT, false, false);
    check_getSmallAlignmentImage(CellConstraints.TOP, false, true);
    check_getSmallAlignmentImage(CellConstraints.CENTER, false, true);
    check_getSmallAlignmentImage(CellConstraints.BOTTOM, false, true);
    check_getSmallAlignmentImage(CellConstraints.FILL, false, true);
}

From source file:org.openthinclient.console.nodes.pkgmgr.DialogPackageDetailView.java

License:Open Source License

@Override
public JComponent getHeaderComponent() {
    // make sure that the main component has been initialized
    getMainComponent();/*  w w  w.  java 2s .c  o m*/

    final DefaultFormBuilder dfb = new DefaultFormBuilder(new FormLayout("p, 10dlu, r:p, 3dlu, f:p:g")); //$NON-NLS-1$
    dfb.setDefaultDialogBorder();
    dfb.setLeadingColumnOffset(2);
    dfb.setColumn(3);

    queryField = new JTextField();
    dfb.append(Messages.getString("DirObjectListNode.filter"), queryField); //$NON-NLS-1$
    dfb.nextLine();

    queryField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            tableModel.setFilter(queryField.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            tableModel.setFilter(queryField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            tableModel.setFilter(queryField.getText());
        }

        @Override
        protected void finalize() throws Throwable {
            tableModel.setFilter("");
            packagesTable.clearSelection();
            super.finalize();
        }

    });

    dfb.add(new JLabel(
            IconManager.getInstance(DetailViewProvider.class, "icons").getIcon("tree." + "PackageListQuery")), //$NON-NLS-1$ //$NON-NLS-2$
            new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP));

    return dfb.getPanel();
}

From source file:org.openthinclient.console.nodes.pkgmgr.PackageDetailView.java

License:Open Source License

@Override
public JComponent getHeaderComponent() {
    // make sure that the main component has been initialized

    getMainComponent();/*  www  .j  a  v  a  2 s.c  o  m*/

    final DefaultFormBuilder dfb = new DefaultFormBuilder(new FormLayout("p, 10dlu, r:p, 3dlu, f:p:g")); //$NON-NLS-1$
    dfb.setDefaultDialogBorder();
    dfb.setLeadingColumnOffset(2);
    dfb.setColumn(3);

    queryField = new JTextField();
    dfb.append(Messages.getString("DirObjectListNode.filter"), queryField); //$NON-NLS-1$
    dfb.nextLine();

    queryField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            tableModel.setFilter(queryField.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            tableModel.setFilter(queryField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            tableModel.setFilter(queryField.getText());
        }

        @Override
        protected void finalize() throws Throwable {
            // System.out.println("PackageDetailView/DocumentListener/finalize");
            tableModel.setFilter("");
            super.finalize();
        }
    });

    dfb.add(new JLabel(
            IconManager.getInstance(DetailViewProvider.class, "icons").getIcon("tree.PackageListQuery")), //$NON-NLS-1$ //$NON-NLS-2$
            new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP));

    return dfb.getPanel();
}

From source file:org.openthinclient.console.nodes.views.DirectoryEntryDetailView.java

License:Open Source License

@Override
public JComponent getHeaderComponent() {
    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("p, 10dlu, p, 0dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle());/*from  ww w.j a  v a2s. co  m*/
    dfb.setLeadingColumnOffset(2);
    dfb.setColumn(3);

    Font f = UIManager.getFont("TitledBorder.font"); //$NON-NLS-1$
    f = f.deriveFont(Font.BOLD, AffineTransform.getScaleInstance(1.5, 1.5));

    final JLabel nameLabel = new JLabel(displayName);
    nameLabel.setForeground(UIManager.getColor("textHighlight")); //$NON-NLS-1$
    nameLabel.setFont(f);

    final JLabel nameField = new JLabel(dn.substring(rdn.length()));
    nameField.setForeground(UIManager.getColor("textHighlight").brighter()); //$NON-NLS-1$
    nameField.setFont(f);

    final JLabel descField = new JLabel(connectionDescriptor.getLDAPUrl());

    dfb.append(nameLabel, nameField);
    dfb.append(descField, 3);

    dfb.add(new JLabel(new ImageIcon(icon)),
            new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP));

    return dfb.getPanel();
}

From source file:org.openthinclient.console.nodes.views.DirObjectDetailView.java

License:Open Source License

@Override
public JComponent getHeaderComponent() {
    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("p, 10dlu, r:p, 3dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle());//from  w ww. j a  v  a 2  s .c om
    dfb.setLeadingColumnOffset(2);
    dfb.setColumn(3);

    final String simpleClassName = dirObject.getClass().getSimpleName();
    Font f = UIManager.getFont("TitledBorder.font"); //$NON-NLS-1$
    f = f.deriveFont(Font.BOLD, AffineTransform.getScaleInstance(1.5, 1.5));

    final JLabel typeLabel = new JLabel(Messages.getString("types.singular." //$NON-NLS-1$
            + simpleClassName) + ":"); //$NON-NLS-1$
    typeLabel.setForeground(new Color(10, 10, 150));
    typeLabel.setFont(f);
    JLabel nameLabel = new JLabel();
    if (simpleClassName.equals("Realm")) {
        String dn = realm.getConnectionDescriptor().getBaseDN();
        dn = dn.replace("\\,", "#%COMMA%#");
        final String[] s = dn.split(",");
        String nameRealm = "";
        if (s.length > 0) {
            nameRealm = s[0].replace("ou=", "").trim();
            nameRealm = nameRealm.replace("#%COMMA%#", "\\,").trim();
        }
        nameLabel = new JLabel(nameRealm); //$NON-NLS-1$
    } else
        nameLabel = new JLabel(dirObject.getName() != null ? dirObject.getName() : ""); //$NON-NLS-1$
    nameLabel.setForeground(new Color(50, 50, 200));
    nameLabel.setFont(f);

    final JLabel descField = new JLabel(dirObject.getDescription() != null ? dirObject.getDescription() : ""); //$NON-NLS-1$

    dfb.append(typeLabel, nameLabel);
    dfb.append(descField, 3);

    dfb.add(new JLabel(IconManager.getInstance(DetailViewProvider.class, "icons") //$NON-NLS-1$
            .getIcon("tree." + dirObject.getClass().getSimpleName())), //$NON-NLS-1$
            new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP));

    return dfb.getPanel();
}

From source file:org.openthinclient.console.nodes.views.DirObjectEditor.java

License:Open Source License

@Override
public JComponent getHeaderComponent() {
    boolean isMutabel = true;
    boolean isRealm = false;
    final String name = dirObject.getClass().getSimpleName();

    // check if is mutable
    if (!LDAPDirectory.isMutable(dirObject.getClass()))
        isMutabel = false;/*w  w w.  j a  v  a 2 s .  c o  m*/
    if (name.equals("Realm"))
        isRealm = true;

    final JPanel panel = new JPanel();

    final PresentationModel model = new PresentationModel(new ValueHolder(dirObject, true));

    final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("p, 10dlu, r:p, 3dlu, f:p:g"), //$NON-NLS-1$
            Messages.getBundle(), panel);
    dfb.setLeadingColumnOffset(2);
    dfb.setColumn(3);

    if (isMutabel == false) {
        dfb.appendI15d("DirObjectEditor.name", BasicComponentFactory.createLabel(model.getModel("name")));
        dfb.appendI15d("DirObjectEditor.description",
                BasicComponentFactory.createLabel(model.getModel("description")));
    } else if (isRealm == true) {
        // FIXME: make it easier
        String dn = realm.getConnectionDescriptor().getBaseDN();
        dn = dn.replace("\\,", "#%COMMA%#");
        final String[] s = dn.split(",");
        String nameRealm = "";
        if (s.length > 0) {
            nameRealm = s[0].replace("ou=", "").trim();
            nameRealm = nameRealm.replace("#%COMMA%#", "\\,").trim();
        }
        final JTextField field = new javax.swing.JTextField();
        field.setText(nameRealm);
        dfb.appendI15d("DirObjectEditor.name", field); //$NON-NLS-1$
        dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("description"), true)); //$NON-NLS-1$
    } else {
        dfb.appendI15d("DirObjectEditor.name", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("name"), false)); //$NON-NLS-1$
        dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createTextField( //$NON-NLS-1$
                model.getModel("description"), true)); //$NON-NLS-1$
    }

    panel.add(
            new JLabel(IconManager.getInstance(DetailViewProvider.class, "icons") //$NON-NLS-1$
                    .getIcon("tree." + dirObject.getClass().getSimpleName())), //$NON-NLS-1$
            new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP));

    panel.putClientProperty(DirObjectEditor.KEY_VALIDATOR, this);

    return panel;
}

From source file:org.pmedv.blackboard.panels.PartPanel.java

License:Open Source License

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    mainSplitpane = new JSplitPane();
    panel1 = new JPanel();
    filterPanel = new FilterPanel();
    scrollPane1 = new JScrollPane();
    partTable = new AlternatingLineTable();
    imageDescriptionSplitPane = new JSplitPane();
    imagePanel = new JPanel();
    imageLabel = new JLabel();
    bottomPanel = new JPanel();
    label1 = new JLabel();
    partNameField = new JTextField();
    label2 = new JLabel();
    packageTypeField = new JTextField();
    label4 = new JLabel();
    authorField = new JTextField();
    label5 = new JLabel();
    licenseField = new JTextField();
    label3 = new JLabel();
    scrollPane2 = new JScrollPane();
    descriptionPane = new JEditorPane();
    CellConstraints cc = new CellConstraints();

    //======== this ========
    setLayout(new FormLayout("2*($lcgap), default:grow, 2*($lcgap)", "2*($lgap), default:grow, 2*($lgap)"));

    //======== mainSplitpane ========
    {/*from  www  .  j a v a 2  s.  c  om*/

        //======== panel1 ========
        {
            panel1.setLayout(new FormLayout("default:grow", "default, $lgap, fill:default:grow"));
            panel1.add(filterPanel, cc.xy(1, 1));

            //======== scrollPane1 ========
            {
                scrollPane1.setViewportView(partTable);
            }
            panel1.add(scrollPane1, cc.xy(1, 3));
        }
        mainSplitpane.setLeftComponent(panel1);

        //======== imageDescriptionSplitPane ========
        {
            imageDescriptionSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);

            //======== imagePanel ========
            {
                imagePanel.setBorder(LineBorder.createBlackLineBorder());
                imagePanel.setLayout(new FormLayout("default, $lcgap, default:grow, $lcgap, default",
                        "default, $lgap, default:grow, $lgap, default"));

                //---- imageLabel ----
                imageLabel.setText("text");
                imagePanel.add(imageLabel, cc.xy(3, 3, CellConstraints.CENTER, CellConstraints.FILL));
            }
            imageDescriptionSplitPane.setTopComponent(imagePanel);

            //======== bottomPanel ========
            {
                bottomPanel.setLayout(new FormLayout("2*($lcgap), default, $lcgap, default:grow, 2*($lcgap)",
                        "2*($lgap), 5*(default, $lgap), fill:default:grow, 2*($lgap)"));

                //---- label1 ----
                label1.setText(resources.getResourceByKey("PartPanel.partname"));
                bottomPanel.add(label1, cc.xy(3, 3));

                //---- partNameField ----
                partNameField.setEditable(false);
                bottomPanel.add(partNameField, cc.xy(5, 3));

                //---- label2 ----
                label2.setText(resources.getResourceByKey("PartPanel.packagetype"));
                bottomPanel.add(label2, cc.xy(3, 5));

                //---- packageTypeField ----
                packageTypeField.setEditable(false);
                bottomPanel.add(packageTypeField, cc.xy(5, 5));

                //---- label4 ----
                label4.setText(resources.getResourceByKey("PartPanel.author"));
                bottomPanel.add(label4, cc.xy(3, 7));

                //---- authorField ----
                authorField.setEditable(false);
                bottomPanel.add(authorField, cc.xy(5, 7));

                //---- label5 ----
                label5.setText(resources.getResourceByKey("PartPanel.license"));
                bottomPanel.add(label5, cc.xy(3, 9));

                //---- licenseField ----
                licenseField.setEditable(false);
                bottomPanel.add(licenseField, cc.xy(5, 9));

                //---- label3 ----
                label3.setText(resources.getResourceByKey("PartPanel.description"));
                bottomPanel.add(label3, cc.xy(3, 11));

                //======== scrollPane2 ========
                {

                    //---- descriptionPane ----
                    descriptionPane.setEditable(false);
                    scrollPane2.setViewportView(descriptionPane);
                }
                bottomPanel.add(scrollPane2, cc.xywh(3, 13, 3, 1));
            }
            imageDescriptionSplitPane.setBottomComponent(bottomPanel);
        }
        mainSplitpane.setRightComponent(imageDescriptionSplitPane);
    }
    add(mainSplitpane, cc.xy(3, 3, CellConstraints.DEFAULT, CellConstraints.FILL));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:presentation.about.GuiTabAbout.java

License:Open Source License

private void initialize() {
    FormLayout layout = new FormLayout("200:grow, 8dlu, pref:grow", // columns 
            "pref, 4dlu, f:50:grow, 4dlu, pref, 4dlu, f:320:grow, pref"); // rows
    PanelBuilder builder = new PanelBuilder(this, layout);
    builder.setDefaultDialogBorder();//from w  w w .  ja va  2s  .  c  o  m
    CellConstraints cc = new CellConstraints();

    builder.addSeparator(ControlMain.getProperty("label_version"), cc.xy(1, 1));
    builder.add(this.getScrollPaneVersion(), cc.xy(1, 3));
    builder.addSeparator(ControlMain.getProperty("label_authors"), cc.xy(1, 5));
    builder.add(this.getScrollPaneAuthors(), cc.xywh(1, 7, 1, 2));
    builder.add(this.getPanelJGrabberInfo(), cc.xywh(3, 1, 1, 6));
    builder.add(new JLabel(this.getImageLogo()), cc.xywh(3, 7, 1, 1));
    builder.add(this.getLinkHomePage(), cc.xywh(3, 8, 1, 1, CellConstraints.CENTER, CellConstraints.FILL));
}

From source file:presentation.start.GuiTabStart.java

License:Open Source License

private void initialize() {
    FormLayout layout = new FormLayout("250:grow, 10, 180:grow, 30, 190", // columns 
            "10, t:130, pref, pref"); // rows
    PanelBuilder builder = new PanelBuilder(this, layout);
    builder.setDefaultDialogBorder();//from ww w . ja  v a2s . co m
    CellConstraints cc = new CellConstraints();

    builder.add(this.getPanelClient(), cc.xy(1, 2));
    builder.add(this.getPanelInfo(), cc.xyw(3, 2, 3));
    builder.add(this.getPanelNews(), cc.xyw(1, 3, 5));
    builder.add(this.getPanelWarn(), cc.xyw(1, 4, 4));
    builder.add(new JLabel(this.getImageLogo()),
            cc.xywh(5, 4, 1, 1, CellConstraints.CENTER, CellConstraints.BOTTOM));
}