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);
}我们将会在描述特定的边框类型的过程中描述这个类的不同方法。例如,要创建一个具有红线的边框,我们可以使用下面的语句,然后将这个边框关联到一个组件。
Border lineBorder = BorderFactory.createLineBorder(Color.RED);7.1.3 Starting with AbstractBorder
在我们了解javax.swing.border包中单个的边框之前,一个系统边框需要获得特别的关注:AbstractBorder。正如前面所提到的,AbstractBorder类是其他的预定义边框的父类。
创建AbstractBorder
AbstractBorder有一个构造函数:
public AbstractBorder()因为AbstractBorder是其他标准边框的父类,这个构造函数实际是为其他边框类自动调用的。
检测AbstractBorder方法
AbstractBorder类提供了Border接口的三个方法实现。
public Insets getBorderInsets(Component c)AbstractBorder的内部区域是零。每一个预定义的子类要重写getBorderInsets()方法。
public boolean isBorderOpaque()AbstractBorder的默认非透明属性设置为false。这就意味着如果我们需要绘制类似点划线