Search in sources :

Example 31 with CompoundBorder

use of javax.swing.border.CompoundBorder in project intellij-community by JetBrains.

the class DialogWrapper method createSouthPanel.

@NotNull
private JPanel createSouthPanel(@NotNull List<JButton> leftSideButtons, @NotNull List<JButton> rightSideButtons, boolean hasHelpToMoveToLeftSide) {
    JPanel panel = new JPanel(new BorderLayout()) {

        @Override
        public Color getBackground() {
            final Color bg = UIManager.getColor("DialogWrapper.southPanelBackground");
            if (getStyle() == DialogStyle.COMPACT && bg != null) {
                return bg;
            }
            return super.getBackground();
        }
    };
    if (myDoNotAsk != null) {
        myCheckBoxDoNotShowDialog = new JCheckBox(myDoNotAsk.getDoNotShowMessage());
        myCheckBoxDoNotShowDialog.setVisible(myDoNotAsk.canBeHidden());
        myCheckBoxDoNotShowDialog.setSelected(!myDoNotAsk.isToBeShown());
        DialogUtil.registerMnemonic(myCheckBoxDoNotShowDialog, '&');
    }
    JComponent doNotAskCheckbox = createDoNotAskCheckbox();
    final JPanel lrButtonsPanel = new NonOpaquePanel(new GridBagLayout());
    //noinspection UseDPIAwareInsets
    //don't wrap to JBInsets
    final Insets insets = SystemInfo.isMacOSLeopard ? UIUtil.isUnderIntelliJLaF() ? JBUI.insets(0, 8) : JBUI.emptyInsets() : new Insets(8, 0, 0, 0);
    if (rightSideButtons.size() > 0 || leftSideButtons.size() > 0) {
        GridBag bag = new GridBag().setDefaultInsets(insets);
        if (leftSideButtons.size() > 0) {
            JPanel buttonsPanel = createButtonsPanel(leftSideButtons);
            if (rightSideButtons.size() > 0) {
                // leave some space between button groups
                buttonsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
            }
            lrButtonsPanel.add(buttonsPanel, bag.next());
        }
        // left strut
        lrButtonsPanel.add(Box.createHorizontalGlue(), bag.next().weightx(1).fillCellHorizontally());
        if (rightSideButtons.size() > 0) {
            JPanel buttonsPanel = createButtonsPanel(rightSideButtons);
            if (shouldAddErrorNearButtons()) {
                lrButtonsPanel.add(myErrorText, bag.next());
                lrButtonsPanel.add(Box.createHorizontalStrut(10), bag.next());
            }
            lrButtonsPanel.add(buttonsPanel, bag.next());
        }
        if (SwingConstants.CENTER == myButtonAlignment && doNotAskCheckbox == null) {
            // right strut
            lrButtonsPanel.add(Box.createHorizontalGlue(), bag.next().weightx(1).fillCellHorizontally());
        }
    }
    JComponent helpButton = null;
    if (hasHelpToMoveToLeftSide) {
        helpButton = createHelpButton(insets);
    }
    if (helpButton != null || doNotAskCheckbox != null) {
        JPanel leftPanel = new JPanel(new BorderLayout());
        if (helpButton != null)
            leftPanel.add(helpButton, BorderLayout.WEST);
        if (doNotAskCheckbox != null) {
            doNotAskCheckbox.setBorder(JBUI.Borders.emptyRight(20));
            leftPanel.add(doNotAskCheckbox, BorderLayout.CENTER);
        }
        panel.add(leftPanel, BorderLayout.WEST);
    }
    panel.add(lrButtonsPanel, BorderLayout.CENTER);
    if (getStyle() == DialogStyle.COMPACT) {
        final Color color = UIManager.getColor("DialogWrapper.southPanelDivider");
        Border line = new CustomLineBorder(color != null ? color : OnePixelDivider.BACKGROUND, 1, 0, 0, 0);
        panel.setBorder(new CompoundBorder(line, JBUI.Borders.empty(8, 12)));
    } else {
        panel.setBorder(JBUI.Borders.emptyTop(8));
    }
    return panel;
}
Also used : NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) JBColor(com.intellij.ui.JBColor) CompoundBorder(javax.swing.border.CompoundBorder) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) CustomLineBorder(com.intellij.ui.border.CustomLineBorder) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with CompoundBorder

use of javax.swing.border.CompoundBorder in project adempiere by adempiere.

the class StackedBox method addBox.

/**
   * Adds a new component to this <code>StackedBox</code>
   * 
   * @param title
   * @param component
   */
public void addBox(String title, Component component) {
    final JXCollapsiblePane collapsible = new JXCollapsiblePane();
    collapsible.getContentPane().setBackground(Color.WHITE);
    collapsible.add(component);
    collapsible.setBorder(new CompoundBorder(separatorBorder, collapsible.getBorder()));
    Action toggleAction = collapsible.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION);
    // use the collapse/expand icons from the JTree UI
    toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon"));
    toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon"));
    JXHyperlink link = new JXHyperlink(toggleAction);
    link.setText(title);
    link.setFont(link.getFont().deriveFont(Font.BOLD));
    link.setOpaque(true);
    link.setBackground(getTitleBackgroundColor());
    link.setFocusPainted(false);
    link.setUnclickedColor(getTitleForegroundColor());
    link.setClickedColor(getTitleForegroundColor());
    link.setBorder(new CompoundBorder(separatorBorder, BorderFactory.createEmptyBorder(2, 4, 2, 4)));
    link.setBorderPainted(true);
    add(link);
    add(collapsible);
}
Also used : Action(javax.swing.Action) JXCollapsiblePane(org.jdesktop.swingx.JXCollapsiblePane) CompoundBorder(javax.swing.border.CompoundBorder) JXHyperlink(org.jdesktop.swingx.JXHyperlink)

Example 33 with CompoundBorder

use of javax.swing.border.CompoundBorder in project jdk8u_jdk by JetBrains.

the class ContrastMetalTheme method addCustomEntriesToTable.

@Override
public void addCustomEntriesToTable(UIDefaults table) {
    Border blackLineBorder = new BorderUIResource(new LineBorder(getBlack()));
    Border whiteLineBorder = new BorderUIResource(new LineBorder(getWhite()));
    Object textBorder = new BorderUIResource(new CompoundBorder(blackLineBorder, new BasicBorders.MarginBorder()));
    table.put("ToolTip.border", blackLineBorder);
    table.put("TitledBorder.border", blackLineBorder);
    table.put("Table.focusCellHighlightBorder", whiteLineBorder);
    table.put("Table.focusCellForeground", getWhite());
    table.put("TextField.border", textBorder);
    table.put("PasswordField.border", textBorder);
    table.put("TextArea.border", textBorder);
    table.put("TextPane.font", textBorder);
}
Also used : BorderUIResource(javax.swing.plaf.BorderUIResource) LineBorder(javax.swing.border.LineBorder) CompoundBorder(javax.swing.border.CompoundBorder) CompoundBorder(javax.swing.border.CompoundBorder) LineBorder(javax.swing.border.LineBorder) Border(javax.swing.border.Border)

Example 34 with CompoundBorder

use of javax.swing.border.CompoundBorder in project JMRI by JMRI.

the class PositionablePopupUtil method setBorderSize.

public void setBorderSize(int border) {
    borderSize = border;
    if (borderColor != null) {
        outlineBorder = new LineBorder(borderColor, borderSize);
        _parent.setBorder(new CompoundBorder(outlineBorder, borderMargin));
    //setHorizontalAlignment(CENTRE);
    }
    _parent.updateSize();
}
Also used : LineBorder(javax.swing.border.LineBorder) CompoundBorder(javax.swing.border.CompoundBorder)

Example 35 with CompoundBorder

use of javax.swing.border.CompoundBorder in project JMRI by JMRI.

the class PositionablePopupUtil method setMargin.

public void setMargin(int m) {
    margin = m;
    if (_parent.isOpaque()) {
        borderMargin = new LineBorder(getBackground(), m);
    } else {
        borderMargin = BorderFactory.createEmptyBorder(m, m, m, m);
    }
    if (_showBorder) {
        _parent.setBorder(new CompoundBorder(outlineBorder, borderMargin));
    }
    _parent.updateSize();
}
Also used : LineBorder(javax.swing.border.LineBorder) CompoundBorder(javax.swing.border.CompoundBorder)

Aggregations

CompoundBorder (javax.swing.border.CompoundBorder)43 EmptyBorder (javax.swing.border.EmptyBorder)23 Border (javax.swing.border.Border)20 BorderLayout (java.awt.BorderLayout)14 JLabel (javax.swing.JLabel)13 JPanel (javax.swing.JPanel)13 Insets (java.awt.Insets)10 LineBorder (javax.swing.border.LineBorder)9 GridBagConstraints (java.awt.GridBagConstraints)8 GridBagLayout (java.awt.GridBagLayout)8 JButton (javax.swing.JButton)8 TitledBorder (javax.swing.border.TitledBorder)8 ActionEvent (java.awt.event.ActionEvent)7 EtchedBorder (javax.swing.border.EtchedBorder)7 CustomLineBorder (com.intellij.ui.border.CustomLineBorder)5 ActionListener (java.awt.event.ActionListener)5 File (java.io.File)5 JTextField (javax.swing.JTextField)5 NotNull (org.jetbrains.annotations.NotNull)5 Color (java.awt.Color)4