CompoundBorder: to combine borders before associating them with a component. : CompoundBorder « Swing « Java Tutorial






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);
CompoundBorder: to combine borders before associating them with a component.
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);
  }
}








14.104.CompoundBorder
14.104.1.CompoundBorder: to combine borders before associating them with a component.CompoundBorder: to combine borders before associating them with a component.
14.104.2.Creating CompoundBorder with LineBorderCreating CompoundBorder with LineBorder
14.104.3.CompoundBorder with double line borders and Lowered Bevel BorderCompoundBorder with double line borders and Lowered Bevel Border