Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

In this page you can find the example usage for javax.swing JLabel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:simplesqlformatter.formatter.SQLFormatterEditor.java

/**
 * Creates a new instance of a Simple SQL Formatter editor main
 * window./*from   w w w .j av a  2s . co m*/
 * 
 * @param debug
 *        Whether to show the debug window
 */
public SQLFormatterEditor(final boolean debug) {

    setTitle("Simple SQL Formatter");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setIconImage(new ImageIcon(SQLFormatterEditor.class.getResource("/sf.png")) //$NON-NLS-1$
            .getImage());

    panel = getContentPane();
    panel.setLayout(new BorderLayout());

    // Create menus and toolbars
    final JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    final JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    add(toolBar, BorderLayout.NORTH);

    createFileMenu(menuBar, toolBar);
    createEditMenu(menuBar, toolBar);
    createHelpMenu(menuBar, toolBar);

    final Font font = new Font("Monospaced", Font.PLAIN, 12);

    // create text area
    textArea.setFont(font);

    // create debug area
    debugArea.setFont(font);
    debugArea.setEditable(false);
    final JLabel debugTitle = new JLabel("Simple SQL Formatter Debug");
    debugTitle.setBorder(BorderFactory.createEtchedBorder());
    final JPanel debugPanel = new JPanel(new BorderLayout());
    debugPanel.add(debugTitle, BorderLayout.NORTH);
    debugPanel.add(new JScrollPane(debugArea), BorderLayout.CENTER);

    if (debug) {
        // create split pane
        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(textArea),
                debugPanel);
        splitPane.setOneTouchExpandable(true);
        splitPane.setResizeWeight(SPLITPANEWEIGHT);

        panel.add(splitPane, BorderLayout.CENTER);
    } else {
        panel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    }

    statusBar.setBorder(BorderFactory.createEtchedBorder());
    panel.add(statusBar, BorderLayout.SOUTH);

    pack();

}

From source file:storybook.toolkit.swing.SwingUtil.java

public static JPanel createMenuBarSpacer(boolean linie) {
    MigLayout layout = new MigLayout("insets 0", "[1]");
    JPanel panel = new JPanel(layout);
    panel.setOpaque(false);/*from   w w  w .j  a v  a  2  s  .  c  om*/
    JLabel label = new JLabel(" ");
    if (linie) {
        Border border = BorderFactory.createMatteBorder(0, 1, 0, 0, Color.gray);
        label.setBorder(border);
        panel.add(label, "center");
    }
    panel.setMaximumSize(new Dimension(2, 10));
    return panel;
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.renderer.ReportingQueryStatementTreeCellRenderer.java

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {

    final JLabel label = new JLabel();
    if (value instanceof QueryExpression) {
        QueryExpression expression = (QueryExpression) value;

        if (expression instanceof QueryStatement) {
            label.setText("Get patients who have");
        } else if (expression instanceof QueryIntersectionExpression) {
            QueryIntersectionExpression intersectionObject = (QueryIntersectionExpression) expression;
            QueryExpression.QueryOperatorType operatorType = intersectionObject.getOperator();
            if (operatorType != QueryExpression.QueryOperatorType.AND) {
                label.setText("ALL of the following (" + operatorType.toString() + ")");
            } else {
                label.setText("ALL of the following");
            }/* w w w  . ja  v  a 2 s .c  om*/
        } else if (expression instanceof QueryUnionExpression) {
            label.setText("ANY of the following");
        } else if (expression instanceof QueryComponentExpression) {
            QueryComponentExpression componentExpression = (QueryComponentExpression) value;
            TerminologyConstraint includedConstraint = componentExpression.getIncludedConstraint();
            if (includedConstraint != null) {
                String text = humanReadableRender
                        .getHumanReadableLabel((CloseToUserExpression) includedConstraint.getExpression());
                label.setText(text);
            }

            final Collection<TerminologyConstraint> excludedTerms = componentExpression
                    .getExcludedConstraints();
            if (excludedTerms.size() > 0) {
                label.setIcon(icon);
            }

            SwingUtilities.updateComponentTreeUI(label);
        }

        // set label text color based on run time status
        setFontColor(expression, label);
    }

    if (hasFocus) {
        Color lineColor = UIManager.getColor("Tree.selectionBorderColor");
        label.setBorder(BorderFactory.createLineBorder(lineColor));
        label.setBackground(UIManager.getColor("Tree.selectionBackground"));
    } else {
        label.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
        label.setBackground(UIManager.getColor("Tree.background"));
    }

    return label;
}

From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override/*from www  . java 2s  .c  om*/
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}