Example usage for javax.swing.border EmptyBorder EmptyBorder

List of usage examples for javax.swing.border EmptyBorder EmptyBorder

Introduction

In this page you can find the example usage for javax.swing.border EmptyBorder EmptyBorder.

Prototype

@ConstructorProperties({ "borderInsets" })
public EmptyBorder(Insets borderInsets) 

Source Link

Document

Creates an empty border with the specified insets.

Usage

From source file:RigidArea.java

public static void main(String[] args) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(new EmptyBorder(new Insets(40, 60, 40, 60)));

    panel.add(new JButton("Button"));
    panel.add(Box.createRigidArea(new Dimension(0, 5)));
    panel.add(new JButton("Button"));
    panel.add(Box.createRigidArea(new Dimension(0, 5)));
    panel.add(new JButton("Button"));
    panel.add(Box.createRigidArea(new Dimension(0, 5)));
    panel.add(new JButton("Button"));

    JFrame f = new JFrame();
    f.add(panel);/*  www. j  a va 2s.  c  o  m*/
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:BorderExample.java

public static void main(String[] args) {
    JPanel panel = new JPanel(new BorderLayout());
    JPanel top = new JPanel();

    top.setBackground(Color.gray);
    top.setPreferredSize(new Dimension(250, 150));
    panel.add(top);/*from w w w  .  j a  v a  2  s.c  o  m*/

    panel.setBorder(new EmptyBorder(new Insets(10, 20, 30, 40)));
    JFrame f = new JFrame();
    f.add(panel);
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);

}

From source file:Main.java

public TextPrompt(String text, JTextComponent component) {
    this.component = component;
    document = component.getDocument();/*from  w  ww  .ja  v  a 2s . co  m*/

    setText(text);
    setFont(component.getFont());
    setBorder(new EmptyBorder(component.getInsets()));

    component.addFocusListener(this);
    document.addDocumentListener(this);

    component.add(this);
}

From source file:gate.gui.docview.AnnotationStack.java

/**
 * Draw the annotation stack in a JPanel with a GridBagLayout.
 *//*from   w w  w  . j a  va2 s.  co  m*/
public void drawStack() {

    // clear the panel
    removeAll();

    boolean textTooLong = text.length() > maxTextLength;
    int upperBound = text.length() - (maxTextLength / 2);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;

    /**********************
     * First row of text *
     *********************/

    gbc.gridwidth = 1;
    gbc.insets = new java.awt.Insets(10, 10, 10, 10);
    JLabel labelTitle = new JLabel("Context");
    labelTitle.setOpaque(true);
    labelTitle.setBackground(Color.WHITE);
    labelTitle.setBorder(new CompoundBorder(
            new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()),
            new EmptyBorder(new Insets(0, 2, 0, 2))));
    labelTitle.setToolTipText("Expression and its context.");
    add(labelTitle, gbc);
    gbc.insets = new java.awt.Insets(10, 0, 10, 0);

    int expressionStart = contextBeforeSize;
    int expressionEnd = text.length() - contextAfterSize;

    // for each character
    for (int charNum = 0; charNum < text.length(); charNum++) {

        gbc.gridx = charNum + 1;
        if (textTooLong) {
            if (charNum == maxTextLength / 2) {
                // add ellipsis dots in case of a too long text displayed
                add(new JLabel("..."), gbc);
                // skip the middle part of the text if too long
                charNum = upperBound + 1;
                continue;
            } else if (charNum > upperBound) {
                gbc.gridx -= upperBound - (maxTextLength / 2) + 1;
            }
        }

        // set the text and color of the feature value
        JLabel label = new JLabel(text.substring(charNum, charNum + 1));
        if (charNum >= expressionStart && charNum < expressionEnd) {
            // this part is matched by the pattern, color it
            label.setBackground(new Color(240, 201, 184));
        } else {
            // this part is the context, no color
            label.setBackground(Color.WHITE);
        }
        label.setOpaque(true);

        // get the word from which belongs the current character charNum
        int start = text.lastIndexOf(" ", charNum);
        int end = text.indexOf(" ", charNum);
        String word = text.substring((start == -1) ? 0 : start, (end == -1) ? text.length() : end);
        // add a mouse listener that modify the query
        label.addMouseListener(textMouseListener.createListener(word));
        add(label, gbc);
    }

    /************************************
     * Subsequent rows with annotations *
     ************************************/

    // for each row to display
    for (StackRow stackRow : stackRows) {
        String type = stackRow.getType();
        String feature = stackRow.getFeature();
        if (feature == null) {
            feature = "";
        }
        String shortcut = stackRow.getShortcut();
        if (shortcut == null) {
            shortcut = "";
        }

        gbc.gridy++;
        gbc.gridx = 0;
        gbc.gridwidth = 1;
        gbc.insets = new Insets(0, 0, 3, 0);

        // add the header of the row
        JLabel annotationTypeAndFeature = new JLabel();
        String typeAndFeature = type + (feature.equals("") ? "" : ".") + feature;
        annotationTypeAndFeature.setText(!shortcut.equals("") ? shortcut
                : stackRow.getSet() != null ? stackRow.getSet() + "#" + typeAndFeature : typeAndFeature);
        annotationTypeAndFeature.setOpaque(true);
        annotationTypeAndFeature.setBackground(Color.WHITE);
        annotationTypeAndFeature
                .setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250),
                        new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2))));
        if (feature.equals("")) {
            annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type));
        } else {
            annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type, feature));
        }
        gbc.insets = new java.awt.Insets(0, 10, 3, 10);
        add(annotationTypeAndFeature, gbc);
        gbc.insets = new java.awt.Insets(0, 0, 3, 0);

        // add all annotations for this row
        HashMap<Integer, TreeSet<Integer>> gridSet = new HashMap<Integer, TreeSet<Integer>>();
        int gridyMax = gbc.gridy;
        for (StackAnnotation ann : stackRow.getAnnotations()) {
            gbc.gridx = ann.getStartNode().getOffset().intValue() - expressionStartOffset + contextBeforeSize
                    + 1;
            gbc.gridwidth = ann.getEndNode().getOffset().intValue() - ann.getStartNode().getOffset().intValue();
            if (gbc.gridx == 0) {
                // column 0 is already the row header
                gbc.gridwidth -= 1;
                gbc.gridx = 1;
            } else if (gbc.gridx < 0) {
                // annotation starts before displayed text
                gbc.gridwidth += gbc.gridx - 1;
                gbc.gridx = 1;
            }
            if (gbc.gridx + gbc.gridwidth > text.length()) {
                // annotation ends after displayed text
                gbc.gridwidth = text.length() - gbc.gridx + 1;
            }
            if (textTooLong) {
                if (gbc.gridx > (upperBound + 1)) {
                    // x starts after the hidden middle part
                    gbc.gridx -= upperBound - (maxTextLength / 2) + 1;
                } else if (gbc.gridx > (maxTextLength / 2)) {
                    // x starts in the hidden middle part
                    if (gbc.gridx + gbc.gridwidth <= (upperBound + 3)) {
                        // x ends in the hidden middle part
                        continue; // skip the middle part of the text
                    } else {
                        // x ends after the hidden middle part
                        gbc.gridwidth -= upperBound - gbc.gridx + 2;
                        gbc.gridx = (maxTextLength / 2) + 2;
                    }
                } else {
                    // x starts before the hidden middle part
                    if (gbc.gridx + gbc.gridwidth < (maxTextLength / 2)) {
                        // x ends before the hidden middle part
                        // do nothing
                    } else if (gbc.gridx + gbc.gridwidth < upperBound) {
                        // x ends in the hidden middle part
                        gbc.gridwidth = (maxTextLength / 2) - gbc.gridx + 1;
                    } else {
                        // x ends after the hidden middle part
                        gbc.gridwidth -= upperBound - (maxTextLength / 2) + 1;
                    }
                }
            }
            if (gbc.gridwidth == 0) {
                gbc.gridwidth = 1;
            }

            JLabel label = new JLabel();
            Object object = ann.getFeatures().get(feature);
            String value = (object == null) ? " " : Strings.toString(object);
            if (value.length() > maxFeatureValueLength) {
                // show the full text in the tooltip
                label.setToolTipText((value.length() > 500)
                        ? "<html><textarea rows=\"30\" cols=\"40\" readonly=\"readonly\">"
                                + value.replaceAll("(.{50,60})\\b", "$1\n") + "</textarea></html>"
                        : ((value.length() > 100)
                                ? "<html><table width=\"500\" border=\"0\" cellspacing=\"0\">" + "<tr><td>"
                                        + value.replaceAll("\n", "<br>") + "</td></tr></table></html>"
                                : value));
                if (stackRow.getCrop() == CROP_START) {
                    value = "..." + value.substring(value.length() - maxFeatureValueLength - 1);
                } else if (stackRow.getCrop() == CROP_END) {
                    value = value.substring(0, maxFeatureValueLength - 2) + "...";
                } else {// cut in the middle
                    value = value.substring(0, maxFeatureValueLength / 2) + "..."
                            + value.substring(value.length() - (maxFeatureValueLength / 2));
                }
            }
            label.setText(value);
            label.setBackground(AnnotationSetsView.getColor(stackRow.getSet(), ann.getType()));
            label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
            label.setOpaque(true);

            label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type,
                    String.valueOf(ann.getId())));

            // show the feature values in the tooltip
            if (!ann.getFeatures().isEmpty()) {
                String width = (Strings.toString(ann.getFeatures()).length() > 100) ? "500" : "100%";
                String toolTip = "<html><table width=\"" + width
                        + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
                Color color = (Color) UIManager.get("ToolTip.background");
                float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
                color = Color.getHSBColor(hsb[0], hsb[1], Math.max(0f, hsb[2] - hsb[2] * 0.075f)); // darken the color
                String hexColor = Integer.toHexString(color.getRed()) + Integer.toHexString(color.getGreen())
                        + Integer.toHexString(color.getBlue());
                boolean odd = false; // alternate background color every other row

                List<Object> features = new ArrayList<Object>(ann.getFeatures().keySet());
                //sort the features into alphabetical order
                Collections.sort(features, new Comparator<Object>() {
                    @Override
                    public int compare(Object o1, Object o2) {
                        return o1.toString().compareToIgnoreCase(o2.toString());
                    }
                });

                for (Object key : features) {
                    String fv = Strings.toString(ann.getFeatures().get(key));
                    toolTip += "<tr align=\"left\"" + (odd ? " bgcolor=\"#" + hexColor + "\"" : "")
                            + "><td><strong>" + key + "</strong></td><td>"
                            + ((fv.length() > 500)
                                    ? "<textarea rows=\"20\" cols=\"40\" cellspacing=\"0\">" + StringEscapeUtils
                                            .escapeHtml(fv.replaceAll("(.{50,60})\\b", "$1\n")) + "</textarea>"
                                    : StringEscapeUtils.escapeHtml(fv).replaceAll("\n", "<br>"))
                            + "</td></tr>";
                    odd = !odd;
                }
                label.setToolTipText(toolTip + "</table></html>");
            } else {
                label.setToolTipText("No features.");
            }

            if (!feature.equals("")) {
                label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, feature,
                        Strings.toString(ann.getFeatures().get(feature)), String.valueOf(ann.getId())));
            }
            // find the first empty row span for this annotation
            int oldGridy = gbc.gridy;
            for (int y = oldGridy; y <= (gridyMax + 1); y++) {
                // for each cell of this row where spans the annotation
                boolean xSpanIsEmpty = true;
                for (int x = gbc.gridx; (x < (gbc.gridx + gbc.gridwidth)) && xSpanIsEmpty; x++) {
                    xSpanIsEmpty = !(gridSet.containsKey(x) && gridSet.get(x).contains(y));
                }
                if (xSpanIsEmpty) {
                    gbc.gridy = y;
                    break;
                }
            }
            // save the column x and row y of the current value
            TreeSet<Integer> ts;
            for (int x = gbc.gridx; x < (gbc.gridx + gbc.gridwidth); x++) {
                ts = gridSet.get(x);
                if (ts == null) {
                    ts = new TreeSet<Integer>();
                }
                ts.add(gbc.gridy);
                gridSet.put(x, ts);
            }
            add(label, gbc);
            gridyMax = Math.max(gridyMax, gbc.gridy);
            gbc.gridy = oldGridy;
        }

        // add a button at the end of the row
        gbc.gridwidth = 1;
        if (stackRow.getLastColumnButton() != null) {
            // last cell of the row
            gbc.gridx = Math.min(text.length(), maxTextLength) + 1;
            gbc.insets = new Insets(0, 10, 3, 0);
            gbc.fill = GridBagConstraints.NONE;
            gbc.anchor = GridBagConstraints.WEST;
            add(stackRow.getLastColumnButton(), gbc);
            gbc.insets = new Insets(0, 0, 3, 0);
            gbc.fill = GridBagConstraints.BOTH;
            gbc.anchor = GridBagConstraints.CENTER;
        }

        // set the new gridy to the maximum row we put a value
        gbc.gridy = gridyMax;
    }

    if (lastRowButton != null) {
        // add a configuration button on the last row
        gbc.insets = new java.awt.Insets(0, 10, 0, 10);
        gbc.gridx = 0;
        gbc.gridy++;
        add(lastRowButton, gbc);
    }

    // add an empty cell that takes all remaining space to
    // align the visible cells at the top-left corner
    gbc.gridy++;
    gbc.gridx = Math.min(text.length(), maxTextLength) + 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 1;
    add(new JLabel(""), gbc);

    validate();
    updateUI();
}

From source file:com.aw.swing.mvp.binding.component.BndSJTable.java

/**
 * Configure ReadOnly col//from  ww w .j ava 2  s .c o  m
 *
 * @param col
 */
private void configureReadOnlyCell(TableColumn col, final ColumnInfo columnInfo) {
    TableCellRenderer cellRenderer = columnInfo.getCustomCellRenderer();
    if (cellRenderer instanceof JCheckBoxCellRenderer) {
        ((JCheckBoxCellRenderer) cellRenderer).setBndSJTable(this);
    }
    final boolean isTableEditable = isEditable();
    if (cellRenderer == null) {
        cellRenderer = new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                    boolean hasFocus, int row, final int column) {

                Component cmp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
                        column);

                Border border = new EmptyBorder(new Insets(2, 5, 2, 5));
                if (isSelected) {
                    if (isTableEditable) {
                        setBackground(UIColorConstants.BKG_CELL_SELECTED_DISABLED);
                    }
                } else {
                    Color bkgColor = Color.white;
                    Color fontColor = null;
                    if (rowColorBkgChanger != null) {
                        Object obj = getValues().get(row);
                        rowColorBkgChanger.process(obj, cmp);
                    }
                    if (columnInfo.getBackground() != null) {
                        bkgColor = columnInfo.getBackground();
                    }
                    if (columnInfo.getBackground() != null) {
                        fontColor = columnInfo.getFontColor();
                    }
                    if (isTableEditable) {
                        bkgColor = UIColorConstants.BKG_CELL_DISABLED;
                    }
                    if (isAuditingColumn(columnInfo.getFieldName())) {
                        bkgColor = AUDITING_COLUMN_COLOR;
                    }
                    if (cellColorChanger != null) {
                        cellColorChanger.setDefaultColor(bkgColor);
                        Object obj = getValues().get(row);
                        bkgColor = cellColorChanger.getBackGround(obj, row, columnInfo.getFieldName());
                        Color foreGroundColor = cellColorChanger.getForeGround(obj, row,
                                columnInfo.getFieldName());
                        if (foreGroundColor != null) {
                            setForeground(foreGroundColor);
                        }
                    }

                    if (fontColor != null) {
                        setForeground(fontColor);
                    }
                    setBackground(bkgColor);

                }
                setBorder(border);
                return this;
            }
        };
    }
    if (cellRenderer instanceof DefaultTableCellRenderer) {
        ((DefaultTableCellRenderer) cellRenderer).setHorizontalAlignment(columnInfo.getAlignment());
    }
    col.setCellRenderer(cellRenderer);
}

From source file:com.diversityarrays.kdxplore.field.OriginDirectionTraversalChoicePanel.java

private JComponent withInsets(JComponent comp, Insets insets) {
    comp.setBorder(new EmptyBorder(insets));
    return comp;
}

From source file:net.pms.newgui.LooksFrame.java

public JComponent buildContent() {
    JPanel panel = new JPanel(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);/*  ww  w.j ava  2  s  . co  m*/
    toolBar.setRollover(true);

    toolBar.add(new JPanel());

    if (PMS.getConfiguration().useWebInterface()) {
        webinterface = createToolBarButton(Messages.getString("LooksFrame.29"), "button-wif.png");
        webinterface.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String error = null;
                if (PMS.get().getWebInterface() != null && isNotBlank(PMS.get().getWebInterface().getUrl())) {
                    try {
                        URI uri = new URI(PMS.get().getWebInterface().getUrl());
                        try {
                            Desktop.getDesktop().browse(uri);
                        } catch (RuntimeException | IOException be) {
                            LOGGER.error("Cound not open the default web browser: {}", be.getMessage());
                            LOGGER.trace("", be);
                            error = Messages.getString("LooksFrame.BrowserError") + "\n" + be.getMessage();
                        }
                    } catch (URISyntaxException se) {
                        LOGGER.error("Could not form a valid web interface URI from \"{}\": {}",
                                PMS.get().getWebInterface().getUrl(), se.getMessage());
                        LOGGER.trace("", se);
                        error = Messages.getString("LooksFrame.URIError");
                    }
                } else {
                    error = Messages.getString("LooksFrame.URIError");
                }
                if (error != null) {
                    JOptionPane.showMessageDialog(null, error, Messages.getString("Dialog.Error"),
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
        webinterface.setToolTipText(Messages.getString("LooksFrame.30"));
        webinterface.setEnabled(configuration.useWebInterface());
        toolBar.add(webinterface);
        toolBar.addSeparator(new Dimension(20, 1));
    }

    restartIcon = (AnimatedIcon) reload.getIcon();
    restartRequredIcon.start();
    setReloadable(false);
    reload.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reload.setEnabled(false);
            PMS.get().reset();
        }
    });
    reload.setToolTipText(Messages.getString("LooksFrame.28"));
    toolBar.add(reload);

    toolBar.addSeparator(new Dimension(20, 1));
    AbstractButton quit = createToolBarButton(Messages.getString("LooksFrame.5"), "button-quit.png");
    quit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            quit();
        }
    });
    toolBar.add(quit);
    if (System.getProperty(START_SERVICE) != null) {
        quit.setEnabled(false);
    }
    toolBar.add(new JPanel());

    // Apply the orientation to the toolbar and all components in it
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());
    toolBar.applyComponentOrientation(orientation);
    toolBar.setBorder(new EmptyBorder(new Insets(8, 0, 0, 0)));

    panel.add(toolBar, BorderLayout.NORTH);
    panel.add(buildMain(), BorderLayout.CENTER);
    status = new JLabel("");
    status.setBorder(BorderFactory.createEmptyBorder());
    status.setComponentOrientation(orientation);

    // Calling applyComponentOrientation() here would be ideal.
    // Alas it horribly mutilates the layout of several tabs.
    //panel.applyComponentOrientation(orientation);
    panel.add(status, BorderLayout.SOUTH);

    return panel;
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * @return a Triple containing the platform specific Focus Border, Empty Border and Focus Color
 *//*from   w  ww.  j a v a2s.  c o  m*/
public static Triple<Border, Border, Color> getFocusBorders(final Component comp) {
    Triple<Border, Border, Color> focusInfo = new Triple<Border, Border, Color>();
    if (focusInfo.first == null) {
        if (UIHelper.isMacOS()) {
            focusInfo.first = new MacBtnBorder();
            Insets fbInsets = focusInfo.first.getBorderInsets(comp);
            focusInfo.second = new EmptyBorder(fbInsets);

        } else {
            if (UIManager.getLookAndFeel() instanceof PlasticLookAndFeel) {
                focusInfo.third = PlasticLookAndFeel.getFocusColor();
            } else {
                focusInfo.third = UIManager.getColor("Button.focus");
            }

            if (focusInfo.third == null) // Shouldn't happen
            {
                focusInfo.third = Color.YELLOW;
            }

            focusInfo.first = new LineBorder(focusInfo.third, 1, true);
            focusInfo.second = new EmptyBorder(focusBorder.getBorderInsets(comp));
        }
    }
    return focusInfo;
}

From source file:pcgen.gui2.dialog.AboutDialog.java

/**
 * Construct the credits panel. This panel shows basic details
 * about PCGen and lists all involved in it's creation.
 *
 * @return The credits panel.//  ww w. jav  a  2  s.  c om
 */
private JPanel buildCreditsPanel() {

    JLabel versionLabel = new JLabel();
    JLabel dateLabel = new JLabel();
    JLabel javaVersionLabel = new JLabel();
    JLabel leaderLabel = new JLabel();
    JLabel helperLabel = new JLabel();
    JLabel wwwLink = new JLabel();
    JLabel emailLabel = new JLabel();
    JTextField version = new JTextField();
    JTextField releaseDate = new JTextField();
    JTextField javaVersion = new JTextField();
    JTextField projectLead = new JTextField();
    wwwSite = new JButton();
    mailingList = new JButton();
    JTabbedPane monkeyTabPane = new JTabbedPane();

    JPanel aCreditsPanel = new JPanel();
    aCreditsPanel.setLayout(new GridBagLayout());

    // Labels

    versionLabel.setText(LanguageBundle.getString("in_abt_version")); //$NON-NLS-1$
    GridBagConstraints gridBagConstraints1 = buildConstraints(0, 0, GridBagConstraints.WEST);
    gridBagConstraints1.weightx = 0.2;
    aCreditsPanel.add(versionLabel, gridBagConstraints1);

    dateLabel.setText(LanguageBundle.getString("in_abt_release_date")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 1, GridBagConstraints.WEST);
    aCreditsPanel.add(dateLabel, gridBagConstraints1);

    javaVersionLabel.setText(LanguageBundle.getString("in_abt_java_version")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 2, GridBagConstraints.WEST);
    aCreditsPanel.add(javaVersionLabel, gridBagConstraints1);

    leaderLabel.setText(LanguageBundle.getString("in_abt_BD")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 3, GridBagConstraints.WEST);
    aCreditsPanel.add(leaderLabel, gridBagConstraints1);

    wwwLink.setText(LanguageBundle.getString("in_abt_web")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwLink, gridBagConstraints1);

    emailLabel.setText(LanguageBundle.getString("in_abt_email")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(emailLabel, gridBagConstraints1);

    helperLabel.setText(LanguageBundle.getString("in_abt_monkeys")); //$NON-NLS-1$
    gridBagConstraints1 = buildConstraints(0, 6, GridBagConstraints.NORTHWEST);
    aCreditsPanel.add(helperLabel, gridBagConstraints1);

    // Info

    version.setEditable(false);
    String versionNum = PCGenPropBundle.getVersionNumber();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildNumber())) {
        versionNum += " autobuild #" + PCGenPropBundle.getAutobuildNumber();
    }
    version.setText(versionNum);
    version.setBorder(null);
    version.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 0, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints1.weightx = 1.0;
    aCreditsPanel.add(version, gridBagConstraints1);

    releaseDate.setEditable(false);
    String releaseDateStr = PCGenPropBundle.getReleaseDate();
    if (StringUtils.isNotBlank(PCGenPropBundle.getAutobuildDate())) {
        releaseDateStr = PCGenPropBundle.getAutobuildDate();
    }
    releaseDate.setText(releaseDateStr);
    releaseDate.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    releaseDate.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 1, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(releaseDate, gridBagConstraints1);

    javaVersion.setEditable(false);
    javaVersion.setText(
            System.getProperty("java.runtime.version") + " (" + System.getProperty("java.vm.vendor") + ")");
    javaVersion.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    javaVersion.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 2, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(javaVersion, gridBagConstraints1);

    projectLead.setEditable(false);
    projectLead.setText(PCGenPropBundle.getHeadCodeMonkey());
    projectLead.setBorder(new EmptyBorder(new Insets(1, 1, 1, 1)));
    projectLead.setOpaque(false);

    gridBagConstraints1 = buildConstraints(1, 3, GridBagConstraints.WEST);
    gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
    aCreditsPanel.add(projectLead, gridBagConstraints1);

    // Web site button
    wwwSite.setText(PCGenPropBundle.getWWWHome());
    wwwSite.addActionListener(event -> {
        try {
            DesktopBrowserLauncher.viewInBrowser(new URL(wwwSite.getText()));
        } catch (IOException ioe) {
            Logging.errorPrint(LanguageBundle.getString("in_abt_browser_err"), ioe); //$NON-NLS-1$
        }
    });
    gridBagConstraints1 = buildConstraints(1, 4, GridBagConstraints.WEST);
    aCreditsPanel.add(wwwSite, gridBagConstraints1);

    // Mailing list button
    mailingList.setText(PCGenPropBundle.getMailingList());
    mailingList.addActionListener(event -> {
        try {
            DesktopBrowserLauncher.viewInBrowser(new URL(mailingList.getText()));
        } catch (IOException ioe) {
            Logging.errorPrint(LanguageBundle.getString("in_err_browser_err"), ioe); //$NON-NLS-1$
        }
    });
    gridBagConstraints1 = buildConstraints(1, 5, GridBagConstraints.WEST);
    aCreditsPanel.add(mailingList, gridBagConstraints1);

    // Monkey tabbed pane
    gridBagConstraints1 = buildConstraints(1, 6, GridBagConstraints.WEST);
    gridBagConstraints1.gridwidth = 2;
    gridBagConstraints1.weighty = 1.0;
    gridBagConstraints1.fill = GridBagConstraints.BOTH;
    aCreditsPanel.add(monkeyTabPane, gridBagConstraints1);

    monkeyTabPane.add(LanguageBundle.getString("in_abt_code_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getCodeMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_list_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getListMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_test_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getTestMonkeys()));
    monkeyTabPane.add(LanguageBundle.getString("in_abt_eng_mky"), //$NON-NLS-1$
            buildMonkeyList(PCGenPropBundle.getEngineeringMonkeys()));

    // because there isn't one
    monkeyTabPane.setToolTipTextAt(2, LanguageBundle.getString("in_abt_easter_egg")); //$NON-NLS-1$

    return aCreditsPanel;
}

From source file:views.online.Panel_RejoindrePartieMulti.java

/**
 * Constructeur/*from w w w .j  a  va2s  . c o m*/
 * 
 * @param parent le fenetre parent
 */
public Panel_RejoindrePartieMulti(JFrame parent) {
    // initialisation
    super(new BorderLayout());
    this.parent = parent;
    parent.setTitle(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL)));
    setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // ---------
    // -- TOP --
    // ---------
    JPanel pTop = new JPanel(new BorderLayout());
    pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    JLabel titre = new JLabel(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    titre.setFont(ManageFonts.POLICE_TITRE);
    titre.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    pTop.add(titre, BorderLayout.NORTH);

    // filtre
    JPanel pADroite = new JPanel(new BorderLayout());
    pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    tfFiltre.setPreferredSize(new Dimension(100, 25));
    tfFiltre.addKeyListener(this);
    tfFiltre.addMouseListener(this);

    pADroite.add(tfFiltre, BorderLayout.WEST);
    pTop.add(pADroite, BorderLayout.CENTER);
    ManageFonts.setStyle(bRafraichir);
    pTop.add(bRafraichir, BorderLayout.EAST);
    bRafraichir.addActionListener(this);

    add(pTop, BorderLayout.NORTH);

    // ------------
    // -- CENTER --
    // ------------

    // cration de la table avec boquage des editions
    tbServeurs = new JTable(model) {
        public boolean isCellEditable(int rowIndex, int colIndex) {
            return false; // toujours dsactiv
        }
    };

    // Simple selection
    tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // nom de colonnes
    model.addColumn(Language.getTexte(Language.ID_TXT_NOM));
    model.addColumn(Language.getTexte(Language.ID_TXT_IP));
    model.addColumn(Language.getTexte(Language.ID_TXT_PORT));
    model.addColumn(Language.getTexte(Language.ID_TXT_MODE));
    model.addColumn(Language.getTexte(Language.ID_TXT_TERRAIN));
    model.addColumn(Language.getTexte(Language.ID_TXT_PLACES_DISPO));

    // Cration du canal avec le serveur d'enregistrement
    try {
        canalServeurEnregistrement = new ChannelTCP(Configuration.getIpSE(), Configuration.getPortSE());

        mettreAJourListeDesServeurs();
    } catch (ConnectException e) {
        connexionSEImpossible();
    } catch (ChannelException e) {
        connexionSEImpossible();
    }

    // ajout dans le panel
    add(new JScrollPane(tbServeurs), BorderLayout.CENTER);

    // ------------
    // -- BOTTOM --
    // ------------
    JPanel pBottom = new JPanel(new BorderLayout());
    pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    bRetour.addActionListener(this);
    ManageFonts.setStyle(bRetour);
    bRetour.setPreferredSize(new Dimension(80, 50));
    pBottom.add(bRetour, BorderLayout.WEST);

    JPanel bottomCenter = new JPanel();
    bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // connexion par IP 
    lblConnexionParIP.setFont(ManageFonts.POLICE_SOUS_TITRE);
    lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblConnexionParIP);
    tfConnexionParIP.setPreferredSize(new Dimension(100, 25));
    bottomCenter.add(tfConnexionParIP);
    tfConnexionParIP.addMouseListener(this);

    // pseudo
    JPanel pPseudo = new JPanel();
    JPanel pTmp = new JPanel();

    lblPseudo.setFont(ManageFonts.POLICE_SOUS_TITRE);
    lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblPseudo);

    tfPseudo.setText(Configuration.getPseudoJoueur());
    bottomCenter.add(tfPseudo);

    pPseudo.add(pTmp, BorderLayout.EAST);
    pBottom.add(bottomCenter, BorderLayout.CENTER);

    // bouton rejoindre
    bRejoindre.setPreferredSize(new Dimension(100, 50));
    ManageFonts.setStyle(bRejoindre);
    pBottom.add(bRejoindre, BorderLayout.EAST);
    bRejoindre.addActionListener(this);

    pBottom.add(lblEtat, BorderLayout.SOUTH);

    add(pBottom, BorderLayout.SOUTH);
}