A compound border is composed of two border objects.
You can nest an inside border within the insets of an outside border.
public CompoundBorder()
public static CompoundBorder createCompoundBorder()
public CompoundBorder(Border outside, Border inside)
Border compoundBorder = new CompoundBorder(lineBorder, matteBorder);
public static CompoundBorder createCompoundBorder(Border outside, Border inside)
Border compoundBorder = BorderFactory.createCompoundBorder(lineBorder, matteBorder);
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
public class CompoundBorderLineLineBorder extends JFrame {
public CompoundBorderLineLineBorder() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
JLabel label;
label = new JLabel("Compound - red inside green lines");
label.setBorder(BorderFactory.createCompoundBorder(new LineBorder(
Color.green), new LineBorder(Color.red)));
panel.add(label);
getContentPane().add(panel);
pack();
}
public static void main(String[] args) {
CompoundBorderLineLineBorder s = new CompoundBorderLineLineBorder();
s.setVisible(true);
}
}