
99Rich GUI Using Java Swing
In addition to the component and container classes, Swing also contains many useful utility
classes. For example, BorderFactory facilitates creation of Border objects (the outline
that surrounds the components, giving a colored outline, 3D appearance, or other visual
effects).
38
Here is a sample JButton with a few different borders:
39
import javax.swing.* java.awt.*
jb1 = JButton('Click me #1!');
jb2 = JButton('Click me #2!');
jb3 = JButton('Click me #3!');
etchedBorder = javax.swing.border.EtchedBorder.LOWERED;
jb1.setBorder(BorderFactory.createLineBorder(Color.red));
jb1.setBorder(BorderFactory.createEtchedBorder(etchedBorder)); ...