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

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

Introduction

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

Prototype

public CellConstraints xywh(int col, int row, int colSpan, int rowSpan, String encodedAlignments) 

Source Link

Document

Sets the column, row, width, and height; decodes the horizontal and vertical alignments from the given string.

Examples:

 cc.xywh(1, 3, 2, 1, "left, bottom"); cc.xywh(1, 3, 2, 1, "l, b"); cc.xywh(1, 3, 7, 3, "center, fill"); cc.xywh(1, 3, 7, 3, "c, f"); 

Usage

From source file:com.salas.bb.utils.uif.CoolInternalFrame.java

License:Open Source License

/**
 * Sets a new header control component./*from   w  ww.  j  av a2  s .  c  om*/
 *
 * @param newhdrContrlComp the header control component to be set in the header.
 */
public void setHeaderControl(JComponent newhdrContrlComp) {
    JComponent oldhdrContrlComp = getHeaderCtrlComp();
    if (oldhdrContrlComp == newhdrContrlComp)
        return;

    if (oldhdrContrlComp != null) {
        headerPanel.remove(oldhdrContrlComp);
    }

    if (newhdrContrlComp != null) {
        newhdrContrlComp.setBorder(null);
        CellConstraints cc = new CellConstraints();
        headerPanel.add(newhdrContrlComp, cc.xywh(5, 2, 1, 3, "r, c"));
    }
    headerCtrlComp = newhdrContrlComp;
    updateHeader();
    firePropertyChange("toolBar", oldhdrContrlComp, newhdrContrlComp);
}

From source file:com.salas.bb.utils.uif.CoolInternalFrame.java

License:Open Source License

/**
 * Creates the appropriately laied out Header for the CoolInternalFrame.
 *
 * @return the header.//  ww  w.j av  a  2  s  . c  o  m
 */
private JPanel buildHeader() {
    FormLayout layout = new FormLayout("11px, pref, min:grow, 2px, pref, 11px", "6px, pref, 1px, pref, 8px");
    headerPanel = new GradientPanel(layout);

    CellConstraints cc = new CellConstraints();
    headerPanel.add(titleLabel, cc.xy(2, 2));
    headerPanel.add(subtitleLabel, cc.xyw(2, 4, 3));
    if (headerCtrlComp != null)
        headerPanel.add(headerCtrlComp, cc.xywh(5, 2, 1, 3, "r, c"));

    headerPanel.setOpaque(SystemUtils.IS_OS_MAC);
    return headerPanel;
}

From source file:de.dal33t.powerfolder.ui.dialog.BaseDialog.java

License:Open Source License

/**
 * Build//from w  ww  .j a  va2  s  .co  m
 *
 * @return
 */
private void createUIComponent() {
    Window owner = null;
    if (senior == Senior.MAIN_FRAME) {
        owner = getUIController().getMainFrame().getUIComponent();
    }
    dialog = new JDialog(owner, getTitle(), modal ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
    dialog.setResizable(resizable);
    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    FormLayout layout = new FormLayout("pref, pref:grow", "fill:pref:grow, 10dlu, fill:pref");
    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    Icon icon = getIcon();
    JLabel iconLabel = icon != null ? new JLabel(getIcon()) : null;
    if (iconLabel != null) {
        iconLabel.setBorder(Borders.createEmptyBorder("3dlu, 3dlu, 3dlu, 3dlu"));
        builder.add(iconLabel, cc.xywh(1, 1, 1, 1, "right, top"));
    }

    JComponent content = getContent();
    content.setBorder(Borders.createEmptyBorder("3dlu, 3dlu, 3dlu, 3dlu"));
    builder.add(content, cc.xy(2, 1));
    Component buttonBar = getButtonBar();
    ((JComponent) buttonBar).setBorder(Borders.createEmptyBorder("3dlu, 3dlu, 3dlu, 3dlu"));
    builder.add(buttonBar, cc.xyw(1, 3, 2));

    // Add panel to component
    dialog.getContentPane().add(builder.getPanel());

    dialog.getRootPane().setDefaultButton(getDefaultButton());

    // Add escape key as close
    KeyStroke strokeEsc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JComponent rootPane = dialog.getRootPane();
    rootPane.registerKeyboardAction(new CloseAction(), strokeEsc, JComponent.WHEN_IN_FOCUSED_WINDOW);

    dialog.pack();
    int ownerX;
    int ownerY;
    int ownerWidth;
    int ownerHeight;

    if (owner != null && owner.isVisible() && senior == Senior.MAIN_FRAME) {
        ownerX = owner.getX();
        ownerY = owner.getY();
        ownerWidth = owner.getWidth();
        ownerHeight = owner.getHeight();
    } else {
        // Senior.NONE centers dialog on the screen.
        ownerX = 0;
        ownerY = 0;
        ownerWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        ownerHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    }
    int x = ownerX + (ownerWidth - dialog.getWidth()) / 2;
    int y = ownerY + (ownerHeight - dialog.getHeight()) / 2;
    dialog.setLocation(x, y);

    // Decrement open dialog count on close.
    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            decrementOpenDialogCount();
        }

        public void windowClosing(WindowEvent e) {
            decrementOpenDialogCount();
        }
    });
}

From source file:de.dal33t.powerfolder.ui.dialog.ConfigurationLoaderDialog.java

License:Open Source License

private JFrame getFrame() {
    if (frame == null) {
        initComponents();//from   ww w.  j ava  2s  . c o  m

        FormLayout layout = new FormLayout("max(p;150dlu), 3dlu, p",
                "p, 7dlu, p, 3dlu, p, 7dlu, p, 7dlu, 12dlu, 14dlu, p");
        PanelBuilder builder = new PanelBuilder(layout);
        builder.setDefaultDialogBorder();
        CellConstraints cc = new CellConstraints();
        int row = 1;
        builder.addLabel(Translation.getTranslation("config.loader.dialog.info"), cc.xyw(1, row, 3));
        row += 2;
        builder.add(addressBox, cc.xy(1, row));
        builder.add(Help.createWikiLinkButton(getController(), WikiLinks.SERVER_CLIENT_DEPLOYMENT),
                cc.xy(3, row));

        row += 2;
        builder.add(proxySettingsLabel, cc.xywh(1, row, 1, 1, "right, center"));

        row += 2;
        builder.add(neverAskAgainBox, cc.xy(1, row));

        row += 2;
        builder.add(progressBar, cc.xyw(1, row, 3));
        builder.add(infoLabel, cc.xyw(1, row, 3));

        row += 2;
        Component buttonBar = buildButtonBar();
        builder.add(buttonBar, cc.xyw(1, row, 3));
        builder.getPanel().setBackground(Color.WHITE);

        frame = new JFrame(getTitle());
        //frame.setAlwaysOnTop(true);
        // frame.setUndecorated(true);
        frame.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
        frame.setIconImage(Icons.getImageById(Icons.SMALL_LOGO));
        frame.setResizable(false);
        frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                exit();
            }
        });
        frame.getContentPane().add(builder.getPanel());
        frame.getRootPane().setDefaultButton(okButton);
        frame.pack();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((screen.width - frame.getWidth()) / 2, (screen.height - frame.getHeight() - 200) / 2);

        progressBar.setVisible(false);
        infoLabel.setVisible(false);
    }
    return frame;
}

From source file:de.dal33t.powerfolder.ui.dialog.UIUnLockDialog.java

License:Open Source License

private JFrame getFrame() {
    if (frame == null) {
        initComponents();// www  .  jav a 2  s  .  c o  m

        FormLayout layout = new FormLayout("p, 3dlu, p:g",
                "p, 7dlu, p, 0, p, 3dlu, p, 3dlu, p, 7dlu, 12dlu, 14dlu, p");
        PanelBuilder builder = new PanelBuilder(layout);
        builder.setDefaultDialogBorder();
        CellConstraints cc = new CellConstraints();
        int row = 1;

        builder.addLabel(Translation.getTranslation("exp.uilock.dialog.info"), cc.xyw(1, row, 3));
        row += 2;

        serverLabel.setBorder(Borders.createEmptyBorder("0, 0, 3dlu, 0"));
        builder.add(serverLabel, cc.xy(1, row));
        serverInfoLabel.getUIComponent().setBorder(Borders.createEmptyBorder("0, 0, 3dlu, 0"));
        builder.add(serverInfoLabel.getUIComponent(), cc.xy(3, row));

        row += 2;
        builder.addLabel(LoginUtil.getUsernameLabel(getController()), cc.xy(1, row));
        builder.add(usernameField, cc.xy(3, row));

        row += 2;
        builder.addLabel(Translation.getTranslation("general.password") + ":", cc.xy(1, row));
        builder.add(passwordField, cc.xy(3, row));

        row += 2;
        builder.add(proxySettingsLabel, cc.xywh(3, row, 1, 1, "right, center"));

        row += 2;
        builder.add(progressBar, cc.xyw(1, row, 3));
        builder.add(infoLabel, cc.xyw(1, row, 3));

        row += 2;
        Component buttonBar = buildButtonBar();
        builder.add(buttonBar, cc.xyw(1, row, 3));
        builder.getPanel().setBackground(Color.WHITE);

        frame = new JFrame(getTitle());
        //frame.setAlwaysOnTop(true);
        // frame.setUndecorated(true);
        frame.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
        frame.setIconImage(Icons.getImageById(Icons.SMALL_LOGO));
        frame.setResizable(false);
        frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                exit();
            }
        });
        frame.getContentPane().add(builder.getPanel());
        frame.getRootPane().setDefaultButton(okButton);
        frame.pack();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((screen.width - frame.getWidth()) / 2, (screen.height - frame.getHeight() - 200) / 2);

        progressBar.setVisible(false);
        infoLabel.setVisible(false);
    }
    return frame;
}

From source file:de.dal33t.powerfolder.ui.MainFrame.java

License:Open Source License

private void configureUi() {

    // Display the title pane.
    uiComponent.getRootPane().putClientProperty("Synthetica.titlePane.enabled", Boolean.FALSE);
    uiComponent.getRootPane().updateUI();

    FormLayout layout = new FormLayout("fill:pref:grow, pref, 3dlu, pref", "pref, pref, fill:0:grow");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    CellConstraints cc = new CellConstraints();

    builder.add(logoLabel, cc.xyw(1, 1, 3));

    ButtonBarBuilder b = new ButtonBarBuilder();
    b.addFixed(minusButton);//from  w  ww . j  a  va 2s. c o m
    b.addFixed(plusButton);
    b.addFixed(closeButton);
    builder.add(b.getPanel(), cc.xywh(4, 1, 1, 1, "right, top"));

    builder.add(inlineInfoLabel, cc.xy(2, 1, CellConstraints.DEFAULT, CellConstraints.BOTTOM));
    builder.add(inlineInfoCloseButton, cc.xy(4, 1, CellConstraints.DEFAULT, CellConstraints.BOTTOM));

    builder.add(centralPanel, cc.xyw(1, 3, 4));

    builder.add(createMiniPanel(), cc.xyw(1, 2, 4));

    uiComponent.getContentPane().removeAll();
    uiComponent.getContentPane().add(builder.getPanel());
    uiComponent.setResizable(true);

    Controller c = getController();

    // Pack elements and set to default size.
    uiComponent.pack();
    uiComponent.setSize(uiComponent.getWidth(), UIConstants.MAIN_FRAME_DEFAULT_HEIGHT);

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = ge.getScreenDevices();

    int x = (int) ((devices[0].getDisplayMode().getWidth() - uiComponent.getWidth()) / 2.0);
    int y = (int) ((devices[0].getDisplayMode().getHeight() - uiComponent.getHeight()) / 2.0);
    uiComponent.setLocation(x, y);

    configureInlineInfo();
    updateMainStatus(SyncStatusEvent.NOT_STARTED);
    updateNoticesLabel();
}

From source file:de.dal33t.powerfolder.ui.preferences.NetworkSettingsTab.java

License:Open Source License

/**
 * Creates the JPanel for advanced settings
 *
 * @return the created panel/*from  w  w  w  .j  av a 2 s  .c  o  m*/
 */
public JPanel getUIPanel() {
    if (panel == null) {
        FormLayout layout;
        if (getController().isBackupOnly()) {
            layout = new FormLayout("right:pref, 3dlu, 140dlu, pref:grow",
                    "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 6dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref");
        } else {
            // Extra pref for useOnlineStorageCB.
            layout = new FormLayout("right:pref, 3dlu, 140dlu, pref:grow",
                    "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref");
        }
        PanelBuilder builder = new PanelBuilder(layout);
        builder.setBorder(Borders.createEmptyBorder("3dlu, 3dlu, 3dlu, 3dlu"));
        CellConstraints cc = new CellConstraints();

        int row = 1;
        builder.addLabel(Translation.getTranslation("exp.preferences.network_mode_name"), cc.xy(1, row));
        builder.add(networkingModeCombo, cc.xy(3, row));

        row += 2;
        builder.add(relayedConnectionCB, cc.xy(3, row));

        row += 2;
        builder.add(udtConnectionCB, cc.xy(3, row));

        row += 2;
        builder.add(ButtonBarFactory.buildLeftAlignedBar(httpProxyButton), cc.xy(3, row));

        row += 2;
        builder.addLabel(Translation.getTranslation("exp.preferences.network.line_settings"),
                cc.xywh(1, row, 1, 1, "default, top"));
        builder.add(wanSpeed.getUiComponent(), cc.xyw(3, row, 2));

        row += 2;
        builder.addLabel(Translation.getTranslation("exp.preferences.network.lan_line_settings"),
                cc.xywh(1, row, 1, 1, "default, top"));
        builder.add(lanSpeed.getUiComponent(), cc.xyw(3, row, 2));

        row += 2;
        builder.addLabel(Translation.getTranslation("exp.preferences.network.adv_port"), cc.xy(1, row))
                .setToolTipText(Translation.getTranslation("exp.preferences.network.adv_port_tooltip"));
        builder.add(advPortTF, cc.xy(3, row));

        row += 2;
        builder.add(randomPortCB, cc.xy(3, row));

        if (FirewallUtil.isFirewallAccessible()) {
            row += 2;
            builder.add(openPortCB, cc.xy(3, row));
        }

        row += 2;
        builder.addLabel(Translation.getTranslation("exp.preferences.network.bind"), cc.xy(1, row))
                .setToolTipText(Translation.getTranslation("exp.preferences.network.bind_tooltip"));
        builder.add(bindAddressCombo, cc.xy(3, row));

        row += 2;
        builder.addLabel(Translation.getTranslation("exp.preferences.network.ip_lan_list"),
                cc.xywh(1, row, 1, 1, "default, top"));
        builder.add(lanList.getUIPanel(), cc.xy(3, row));

        panel = builder.getPanel();
    }
    return panel;
}

From source file:de.dal33t.powerfolder.ui.wizard.BasicSetupPanel.java

License:Open Source License

protected JPanel buildContent() {
    FormLayout layout = new FormLayout("right:pref, 3dlu, 100dlu, pref:grow",
            "pref, 6dlu, pref, 6dlu, pref, 6dlu, top:pref");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(createFewContentBorder());
    CellConstraints cc = new CellConstraints();

    builder.addLabel(Translation.getTranslation("exp.wizard.basic_setup.computer_name"), cc.xy(1, 1));
    builder.add(nameField, cc.xy(3, 1));
    builder.addLabel(Translation.getTranslation("preferences.network.line_settings"),
            cc.xywh(1, 3, 1, 1, "default, top"));
    builder.add(wanLineSpeed.getUiComponent(), cc.xy(3, 3));
    builder.addLabel(Translation.getTranslation("exp.wizard.basic_setup.language_restart"), cc.xy(1, 5));
    builder.add(languageChooser, cc.xy(3, 5));
    builder.add(defaultFolderHelper.getUIComponent(), cc.xyw(3, 7, 2));

    return builder.getPanel();
}

From source file:de.dal33t.powerfolder.ui.wizard.PFWizardPanel.java

License:Open Source License

/**
 * Builds the ui/*from   ww w.  ja  v a 2  s  . c o m*/
 */
private void buildUI() {

    // init
    initComponents();

    JComponent content = buildContent();
    content.setOpaque(false);
    // content.setBackground(Color.WHITE);

    String title = getTitle();

    Reject.ifBlank(title, "Title is blank");
    Reject.ifNull(content, "Content is null");

    setBorder(Borders.EMPTY_BORDER);

    FormLayout layout = new FormLayout("13px, fill:pref:grow", "pref, 7dlu, pref, 3dlu, fill:pref:grow");
    PanelBuilder pageBuilder = new PanelBuilder(layout, this);
    pageBuilder.setBorder(Borders.createEmptyBorder("7dlu, 20dlu, 0dlu, 20dlu"));
    CellConstraints cc = new CellConstraints();
    int row = 1;

    pageBuilder.add(new JLabel(Icons.getIconById(Icons.LOGO400UI)), cc.xywh(1, row, 2, 1, "left, default"));
    row += 2;

    titleLabel = createTitleLabel(title);
    pageBuilder.add(titleLabel, cc.xy(2, row));
    row += 2;

    pageBuilder.add(content, cc.xy(2, row, CellConstraints.DEFAULT, CellConstraints.TOP));

    // initalized
    initalized = true;
}

From source file:fileCompare.gui.ErrorLog.java

License:Open Source License

public JComponent buildPanel() {
    FormLayout layout = new FormLayout("m:grow, m:grow", //cols
            "m:grow, 4dlu, pref"); //rows
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.setDefaultDialogBorder();//from  w w  w.  ja  v  a  2s  . co  m
    CellConstraints cc = new CellConstraints();
    int y = 1;
    builder.add(new JScrollPane(errorLog_), cc.xywh(1, y++, 2, 1, "fill, fill"));
    y++;
    builder.add(clear_, cc.xy(1, y, "center, fill"));
    builder.add(close_, cc.xy(2, y++, "center, fill"));
    return builder.getPanel();
}