There are several types of borders available, each represented by its own class. A border can be created using the class' constructor or using a border factory. The border factory is the typical method for creating a border since it creates the border using values that are compatible with the current look and feel. However, if custom values are required, the border should be created using a constructor.
This example creates one of each of the available borders. See also e874 Adding a Title to a Border.
// Create a border
EmptyBorder emptyBorder = (EmptyBorder)BorderFactory.createEmptyBorder();
LineBorder lineBorder = (LineBorder)BorderFactory.createLineBorder(Color.black);
EtchedBorder etchedBorder = (EtchedBorder)BorderFactory.createEtchedBorder();
BevelBorder raisedBevelBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
BevelBorder loweredBevelBorder = (BevelBorder)BorderFactory.createLoweredBevelBorder();
ImageIcon icon = new ImageIcon("image.gif");
MatteBorder matteBorder = (MatteBorder)BorderFactory.createMatteBorder(-1, -1, -1, -1, icon);
// Set the border
component.setBorder(emptyBorder);