Example usage for javax.swing BorderFactory createLineBorder

List of usage examples for javax.swing BorderFactory createLineBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createLineBorder.

Prototype

public static Border createLineBorder(Color color) 

Source Link

Document

Creates a line border with the specified color.

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("Some label text");
    label.setBorder(BorderFactory.createLineBorder(Color.green));
    label.setFont(new Font("Serif", Font.ITALIC, 16));

    getContentPane().add(label);/*w w  w. j  a v  a2s .c  om*/
    pack();
    setVisible(true);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLUE),
            "Title Line Border with color"));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/*w w w  .  j  a v  a 2 s.co m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    JLabel lineBorderLabel = new JLabel("Line Border", JLabel.CENTER);
    lineBorderLabel.setBorder(BorderFactory.createLineBorder(Color.black));
    simplePanel.add(lineBorderLabel);/*w w  w.  java2s.  c o  m*/

    add(simplePanel);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));
    ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit().getImage("matte.gif"));
    simplePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red),
            BorderFactory.createMatteBorder(-1, -1, -1, -1, icon)));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);//from  w w w.  jav a2  s . co  m
}

From source file:Main.java

public Main() {
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);

    this.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.anchor = GridBagConstraints.NORTH;
    gbc.weighty = 0.0;//from   w w w. j av a 2 s . c  o  m

    JPanel one = new JPanel();
    one.setPreferredSize(new Dimension(200, 200));
    one.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    JPanel two = new JPanel();
    two.setPreferredSize(new Dimension(200, 200));
    two.setBorder(BorderFactory.createLineBorder(Color.BLACK));

    this.add(one, gbc);

    gbc.gridy = 1;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.VERTICAL;

    this.add(two, gbc);

    this.pack();
    this.setVisible(true);
}

From source file:Main.java

public Main() {
    StringBuilder sb = new StringBuilder();
    sb.append("<html><body>");
    sb.append("1");
    sb.append("<sup>");
    sb.append("2");
    sb.append("</sup>");
    sb.append("<font size=+1>/<font size=-1>");
    sb.append("<sub>");
    sb.append("3");
    sb.append("</sub>");
    sb.append("</html></body>");
    JLabel label = new JLabel(sb.toString(), JLabel.CENTER);
    label.setBorder(BorderFactory.createLineBorder(Color.lightGray));
    add(label);// w w w .jav a 2 s.c o m
}

From source file:BorderTest.java

public BorderTest() {
    JPanel p = new JPanel();
    Border[] border = new Border[] { BorderFactory.createEtchedBorder(),
            BorderFactory.createTitledBorder("Border types"), BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createRaisedBevelBorder(), BorderFactory.createEtchedBorder(),
            BorderFactory.createLineBorder(Color.blue),
            BorderFactory.createMatteBorder(10, 10, 10, 10, Color.blue), BorderFactory.createEmptyBorder()

    };/*from  w  w w. j a  va  2 s  .c  o m*/
    p.setLayout(new GridLayout(border.length, 0, 3, 3));

    for (int i = 0; i < border.length; i++) {
        JPanel borderPanel = new JPanel();
        borderPanel.setBorder(border[i]);
        p.add(borderPanel);
    }
    getContentPane().add(p, "Center");
    setTitle("BorderTest");
    setSize(600, 400);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

From source file:ImageLabelExample.java

protected static JLabel makeLabel(int vert, int horiz) {
    JLabel l = new JLabel("Smile", icon, SwingConstants.CENTER);
    l.setVerticalTextPosition(vert);/*from  ww w .  j  a  v a 2  s  . c o  m*/
    l.setHorizontalTextPosition(horiz);
    l.setBorder(BorderFactory.createLineBorder(Color.black));
    return l;
}

From source file:Main.java

public TestPane() {
    setLayout(new BorderLayout());
    setBorder(new EmptyBorder(10, 10, 10, 10));
    JTextPane pane = new JTextPane();
    JPanel panel = new JPanel(new BorderLayout());
    JPanel innerPanel = new JPanel(new BorderLayout());

    pane.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    innerPanel.add(pane);/*from www. j a  v a2s. com*/
    panel.add(innerPanel);
    add(panel);
}

From source file:MainClass.java

public JPanel createNested(boolean opaque) {
    JPanel outer = new JPanel(new FlowLayout());
    JPanel inner = new JPanel(new FlowLayout());
    outer.setBackground(Color.white);
    inner.setBackground(Color.black);

    inner.setOpaque(opaque);//from   w ww .  j  ava 2  s . c o m
    inner.setBorder(BorderFactory.createLineBorder(Color.gray));

    inner.add(new JButton("Button"));
    outer.add(inner);

    return outer;
}