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 static void main(String[] argv) {
    LineBorder lineBorder = (LineBorder) BorderFactory.createLineBorder(Color.black);
    JLabel component = new JLabel("label");
    component.setBorder(lineBorder);//from w ww  .ja v  a2s  .  c  om

}

From source file:Main.java

public static void main(String[] args) {

    JLabel label = new JLabel("java2s.com", JLabel.LEFT);
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);/*from   w  w w  .j a va 2 s  .c o m*/

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Fourth Button");
    Container contentPane = frame.getContentPane();
    JButton b = new JButton("Button!");
    Border bored = BorderFactory.createLineBorder(Color.RED);
    b.setBorder(bored);//from w  w w  .j a  v a2s  . co m
    contentPane.add(b, BorderLayout.CENTER);
    frame.setSize(350, 200);
    frame.show();
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.RED));
    BoxLayout mgr = new BoxLayout(panel, BoxLayout.Y_AXIS);
    panel.setLayout(mgr);//from w ww  .  ja  v  a  2  s  .  c  o  m
    for (int i = 0; i < 5; i++) {
        JButton button = new JButton("Remove Hello World " + (i + 1));
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        button.addActionListener(e -> {
            panel.remove(button);
            panel.revalidate();
            panel.repaint();
        });
        panel.add(button);
    }
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);//from   w  ww  .j  a  va  2  s .  com
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("A default label");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);
    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

License:asdf

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);/* w ww.  j a v  a2  s.co  m*/
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);
    label.setPreferredSize(new Dimension(150, 100));
    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

License:asdf

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);/*from  w  ww.j  av  a2 s .  com*/
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);
    label.setPreferredSize(new Dimension(150, 100));

    label.setText("Centered");
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setVerticalAlignment(JLabel.CENTER);

    f.add(label);
    f.setVisible(true);
}

From source file:Main.java

License:asdf

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);// ww w .j  a  v a  2  s  .co m
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);
    label.setPreferredSize(new Dimension(150, 100));

    label.setText("Top Left");
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.TOP);

    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

License:asdf

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);/*w ww  .  ja va2 s  . c  om*/
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);
    label.setPreferredSize(new Dimension(150, 100));

    label.setText("Bottom Right");
    label.setHorizontalAlignment(JLabel.RIGHT);
    label.setVerticalAlignment(JLabel.BOTTOM);

    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

License:asdf

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setSize(200, 360);//w w w.j  a va2s .co  m
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("asdf");
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);
    label.setPreferredSize(new Dimension(150, 100));

    label.setText("Centered");
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setVerticalAlignment(JLabel.CENTER);

    f.add(label);

    f.setVisible(true);
}