Introducing BorderFactory : BorderFactory « Swing « Java Tutorial






BorderFactory class offers a series of static methods for creating predefined borders.

public class BorderFactory {
  public static Border createBevelBorder(int type);
  public static Border createBevelBorder(int type, Color highlight, Color shadow);
  public static Border createBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner);

  public static CompoundBorder createCompoundBorder();
  public static CompoundBorder createCompoundBorder(Border outside, Border inside);

  public static Border createEmptyBorder();
  public static Border createEmptyBorder(int top, int left, int bottom, int right);

  public static Border createEtchedBorder();
  public static Border createEtchedBorder(Color highlight, Color shadow);
  public static Border createEtchedBorder(int type);
  public static Border createEtchedBorder(int type, Color highlight, Color shadow);

  public static Border createLineBorder(Color color);
  public static Border createLineBorder(Color color, int thickness);

  public static Border createLoweredBevelBorder();

  public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Color color);
  public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Icon icon);
  public static Border createRaisedBevelBorder();

  public static TitledBorder createTitledBorder(Border border);
  public static TitledBorder createTitledBorder(Border border, String title);
  public static TitledBorder createTitledBorder(Border border, String title, int justification, int position);
  public static TitledBorder createTitledBorder(Border border, String title, int justification, int position, Font font);
  public static TitledBorder createTitledBorder(Border border, String title, int justification, int position, Font font, Color color);
  public static TitledBorder createTitledBorder(String title);
}








14.109.BorderFactory
14.109.1.Introducing BorderFactory
14.109.2.BorderFactory in action
14.109.3.Use BorderFactory to create borders
14.109.4.BorderFactory.createEmptyBorder
14.109.5.BorderFactory.createLineBorder: create line border
14.109.6.BorderFactory.createEtchedBorder: create Etched Border
14.109.7.BorderFactory.createEtchedBorder: LOWERED EtchedBorder
14.109.8.BorderFactory.createRaisedBevelBorder
14.109.9.BorderFactory.createLoweredBevelBorder
14.109.10.BorderFactory.createEmptyBorder(10, 10, 10, 10)
14.109.11.BorderFactory.createTitledBorder('Title Border')
14.109.12.BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLUE), "Title Line Border with color")
14.109.13.BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Title Lowered Etched Border")
14.109.14.BorderFactory.createMatteBorder(2, 5, 2, 5, Color.BLUE)
14.109.15.BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder())
14.109.16.BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), BorderFactory.createMatteBorder(-1, -1, -1, -1, icon))