Example usage for com.jgoodies.forms.builder ButtonStackBuilder addFixed

List of usage examples for com.jgoodies.forms.builder ButtonStackBuilder addFixed

Introduction

In this page you can find the example usage for com.jgoodies.forms.builder ButtonStackBuilder addFixed.

Prototype

public ButtonStackBuilder addFixed(JComponent component) 

Source Link

Document

Adds a fixed size component.

Usage

From source file:ca.sqlpower.swingui.db.DatabaseConnectionManager.java

License:Open Source License

private JPanel createPanel(List<Action> additionalActions, List<JComponent> additionalComponents,
        boolean showCloseButton, String message) {

    FormLayout layout = new FormLayout("6dlu, fill:min(160dlu;default):grow, 6dlu, pref, 6dlu", // columns //$NON-NLS-1$
            " 6dlu,10dlu,6dlu,fill:min(180dlu;default):grow,10dlu"); // rows //$NON-NLS-1$

    layout.setColumnGroups(new int[][] { { 1, 3, 5 } });
    CellConstraints cc = new CellConstraints();

    PanelBuilder pb;//  w w w .  jav a  2 s .c  o m
    JPanel p = logger.isDebugEnabled() ? new FormDebugPanel(layout) : new JPanel(layout);
    pb = new PanelBuilder(layout, p);
    pb.setDefaultDialogBorder();

    pb.add(new JLabel(message), cc.xyw(2, 2, 3)); //$NON-NLS-1$

    TableModel tm = new ConnectionTableModel(dsCollection);
    dsTable = new EditableJTable(tm);
    dsTable.setTableHeader(null);
    dsTable.setShowGrid(false);
    dsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dsTable.addMouseListener(new DSTableMouseListener());
    dsTable.setDefaultRenderer(SPDataSource.class, new ConnectionTableCellRenderer());

    JScrollPane sp = new JScrollPane(dsTable);
    sp.getViewport().setBackground(dsTable.getBackground());

    pb.add(sp, cc.xy(2, 4));

    ButtonStackBuilder bsb = new ButtonStackBuilder();

    JButton newButton = new JButton();
    AbstractAction newDatabaseConnectionAction = new NewConnectionAction(
            Messages.getString("DatabaseConnectionManager.newDbConnectionActionName"), newButton); //$NON-NLS-1$
    newButton.setAction(newDatabaseConnectionAction);
    bsb.addGridded(newButton);
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(editDatabaseConnectionAction));
    bsb.addRelatedGap();
    bsb.addGridded(new JButton(removeDatabaseConnectionAction));

    removeDatabaseConnectionAction.setEnabled(false);
    editDatabaseConnectionAction.setEnabled(false);

    bsb.addUnrelatedGap();
    JButton jdbcDriversButton = new JButton(jdbcDriversAction);
    bsb.addGridded(jdbcDriversButton);

    for (Action a : additionalActions) {
        bsb.addUnrelatedGap();
        JButton b = new JButton(a);
        Object disableValue = a.getValue(DISABLE_IF_NO_CONNECTION_SELECTED);
        if (disableValue instanceof Boolean && disableValue.equals(Boolean.TRUE)) {
            b.setEnabled(false);
        }

        Object heightValue = a.getValue(ADDITIONAL_BUTTON_HEIGHT);
        if (heightValue instanceof Integer) {
            b.setPreferredSize(new Dimension((int) b.getPreferredSize().getWidth(), (Integer) heightValue));
        }

        Object verticalTextPos = a.getValue(VERTICAL_TEXT_POSITION);
        if (verticalTextPos instanceof Integer) {
            Integer verticalTextInt = (Integer) verticalTextPos;
            if (verticalTextInt == SwingConstants.TOP || verticalTextInt == SwingConstants.BOTTOM
                    || verticalTextInt == SwingConstants.CENTER) {
                b.setVerticalTextPosition(verticalTextInt);
            }
        }

        Object horizontalTextPos = a.getValue(HORIZONTAL_TEXT_POSITION);
        if (horizontalTextPos instanceof Integer) {
            Integer horizontalTextInt = (Integer) horizontalTextPos;
            if (horizontalTextInt == SwingConstants.LEFT || horizontalTextInt == SwingConstants.RIGHT
                    || horizontalTextInt == SwingConstants.CENTER || horizontalTextInt == SwingConstants.LEADING
                    || horizontalTextInt == SwingConstants.TRAILING) {
                b.setHorizontalTextPosition(horizontalTextInt);
            }
        }

        additionalActionButtons.add(b);
        bsb.addFixed(b);
    }

    for (JComponent comp : additionalComponents) {
        bsb.addUnrelatedGap();
        bsb.addFixed(comp);
    }

    if (showCloseButton) {
        bsb.addUnrelatedGap();
        bsb.addGridded(new JButton(closeAction));
    }

    pb.add(bsb.getPanel(), cc.xy(4, 4));
    return pb.getPanel();

}

From source file:org.columba.mail.gui.config.folder.FolderOptionsDialog.java

License:Mozilla Public License

/**
 * Create advanced panel./*from w  w  w  . ja v  a2s. c o  m*/
 * <p>
 * 
 * @return panel
 */
protected JPanel createAdvancedPanel() {
    // Create a FormLayout instance.
    FormLayout layout = new FormLayout("fill:default:grow, 6px, default", //$NON-NLS-1$

            // 3 columns
            "pref, 6px, fill:pref:grow"); //$NON-NLS-1$

    // create a form builder
    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    // create EmptyBorder between components and dialog-frame
    builder.setDefaultDialogBorder();

    builder.add(overwriteLabel, cc.xywh(1, 1, 3, 1));

    JScrollPane sp = new JScrollPane(checkableList);
    sp.setPreferredSize(new Dimension(200, 200));
    sp.getViewport().setBackground(Color.white);
    builder.add(sp, cc.xy(1, 3));

    ButtonStackBuilder b = new ButtonStackBuilder();
    b.addGridded(enableButton);
    b.addRelatedGap();
    b.addGridded(disableButton);
    b.addUnrelatedGap();
    b.addGlue();
    b.addFixed(resetButton);

    JPanel buttonPanel = b.getPanel();
    builder.add(buttonPanel, cc.xy(3, 3));

    /*
     * JPanel panel= new JPanel(); panel.setLayout(new BorderLayout());
     * panel.add(resetButton, BorderLayout.EAST); builder.add(panel,
     * cc.xywh(5, 7, 1, 1));
     */
    /*
     * builder.addSeparator("Full-text indexing");
     * 
     * builder.add(enableLabel, cc.xywh(1, 7, 5, 1));
     * builder.add(enableTextIndexingCheckBox, cc.xywh(2, 9, 4, 1));
     */
    return builder.getPanel();
}