Swinging Duke
Feedback Button
Left ArrowRight Arrow

 

The Swing Border API


Swing provides a class named BorderFactory that you can use to create borders for Swing components. The BorderFactory class has replaced the JBorder class that was used in early pre-beta releases of Swing.

The BorderFactory class provides a considerable number of methods for creating borders of various kinds, including bevel borders, compound borders, line borders, etched borders, and more.

To create a border for a component, you simply create the component and then call whatever border-creation method you need. For example, to create a panel with a titled border, you could write a code sequence such as the following:

      p = new JPanel();
      p.setBorder(BorderFactory.createTitledBorder
         ("My Titled Panel"));

More comprehensive documentation for the BorderFactory class is now being developed. Meanwhile, you can find current definitions for the BorderFactory's methods in the JavaDoc API, and you can learn more about how the BorderFactory works by examining the code in the SwingSet sample application and other sample programs provided with Swing.

Arrows


Version 0.5. Last modified 10/1/97.
http:com.sun.java.swing.Copyright © 1995-97 Sun Microsystems, Inc. All Rights Reserved.

Sun's Home Page