Java Swing Tutorial - Java BorderFactory .createLineBorder (Color color, int thickness, boolean rounded)








Syntax

BorderFactory.createLineBorder(Color color, int thickness, boolean rounded) has the following syntax.

public static Border createLineBorder(Color color,   int thickness,   boolean rounded)

Example

In the following code shows how to use BorderFactory.createLineBorder(Color color, int thickness, boolean rounded) method.

//  ww  w  . ja  v a 2 s.  c o m
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.border.Border;

public class Main {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Compound Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton bevelLineButton = new JButton("Bevel Line");
    Border redBorder = BorderFactory.createLineBorder(Color.MAGENTA, 2,true);
    bevelLineButton.setBorder(redBorder);
    
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(bevelLineButton);
    frame.setSize(300, 100);
    frame.setVisible(true);
  }
}