YourFrame.getRootPane().setBorder(
BorderFactory.createMatteBorder(4, 4, 4, 4, Color.RED));
.setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.RED));
import java.awt.*;
import javax.swing.*;
public class BorderFrameExample extends JFrame
{
JLabel l = new JLabel("Welcome!", JLabel.CENTER);
public BorderFrameExample() {
//add label to frame
add(l, BorderLayout.CENTER);
//remove the decoration
setUndecorated(true);
//set border
getRootPane().setBorder(
BorderFactory.createMatteBorder(4, 4, 4, 4, Color.BLUE)
);
setSize(250,250);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new BorderFrameExample();
}
}