BorderFactory Class

Package: javax.swing

tip.eps The BorderFactory class is in the javax.swing package, but the Border interface that defines the resulting border objects is in javax.swing.border.

The BorderFactory class creates decorative borders that are used to visually group components. The frame in Figure 5-1 shows some radio buttons and check boxes inside borders.

9781118239742-fg0501.tif

Figure 5-1

You can apply a border to any object that inherits JComponent, but the usual technique is to apply the border to a panel and add to that panel any components you want to appear within the border.

CrossRef.eps Panels are the usual way to display two or more controls that are visually grouped together. For example, if you want to display several radio buttons together, the usual way is to add the radio buttons to a panel, add a border to the panel, and then add the panel to the frame. For more information, see JPanel Class.

Remember.eps All methods of the BorderFactory class are static. Border Factory has no constructor, so you don’t need to create an instance.

Methods

Method

Description

static Border create BevelBorder(int type) ...

Get Java For Dummies Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.