Java Reference
In-Depth Information
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);
}
I'll describe the different methods of this class during the process of describing the specific
border types they create. For instance, to create a border with a red line, you can use the following
statement, and then attach the border to a component.
Border lineBorder = BorderFactory.createLineBorder(Color.RED);
■
Note
Interestingly enough, no factory method exists for creating a
SoftBevelBorder
.
Starting with AbstractBorder
Before looking at the individual borders available within the
javax.swing.border
package,
one system border deserves special attention:
AbstractBorder
. As previously mentioned, the
AbstractBorder
class is the parent border of all the other predefined borders.
■
Tip
When creating your own borders, you should create a subclass of
AbstractBorder
and just override
the necessary methods, instead of implementing the
Border
interface directly yourself. There are some
internal optimizations in place for subclasses.
Creating Abstract Borders
There is one constructor for
AbstractBorder
:
public AbstractBorder()
Because
AbstractBorder
is the parent class of all the other standard borders, this constructor is
eventually called automatically for all of them.