Creating a Compound Border : Custom Border « Swing « Java Tutorial






import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;

public class Main {
  public static void main(String[] argv) {
    LineBorder border1 = new LineBorder(Color.red);
    TitledBorder border2 = new TitledBorder("asdf");

    Border newBorder = BorderFactory.createCompoundBorder(border1, border2);
    JButton component = new JButton("button");
    component.setBorder(newBorder);
  }
}








14.108.Custom Border
14.108.1.Creating Your Own Borders
14.108.2.implements Border interfaceimplements Border interface
14.108.3.Subclass AbstractBorderSubclass AbstractBorder
14.108.4.Creating a Compound Border
14.108.5.Creating and Setting a Raised BevelBorder from BorderFactory
14.108.6.Creating and Setting a Lowered BevelBorder from BorderFactory