// This example is from _Java Examples in a Nutshell_. (http://www.oreilly.com)
// Copyright (c) 1997 by David Flanagan
// This example is provided WITHOUT ANY WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for non-commercial purposes.
// For any commercial use, see http://www.davidflanagan.com/javaexamples

import com.sun.java.swing.*;       // Beta package name; will change
import com.sun.java.swing.border.*;
import java.awt.*;

/**
 * This class demonstrates some borders that can be displayed 
 * around JFC components.
 **/
public class BorderPanel extends JBorderedPane {
  public BorderPanel() {
    // Set a title for this pane.
    this.setBorder(new JTitledBorder(this, "Borders"));

    // Create an array to hold our bordered components
    JButton buttons[] = new JButton[8];

    // The following 8 components have borders created by JBezelBorder,
    // JGroovedBorder, JLineBorder, and JTitledBorder
    buttons[0] = new JButton("JBezelBorder (lowered)");
    buttons[0].setBorder(new JBezelBorder(JBezelBorder.LOWERED));

    buttons[1] = new JButton("JBezelBorder (raised)");
    buttons[1].setBorder(new JBezelBorder(JBezelBorder.RAISED));

    buttons[2] = new JButton("JGroovedBorder");
    buttons[2].setBorder(new JGroovedBorder());

    buttons[3] = new JButton("JLineBorder (thin)");
    buttons[3].setBorder(new JLineBorder(Color.black, 1));

    buttons[4] = new JButton("JLineBorder (thick)");
    buttons[4].setBorder(new JLineBorder(Color.darkGray, 3));

    buttons[5] = new JButton("JTitledBorder (1)");
    buttons[5].setBorder(new JTitledBorder(this, "Title1"));

    buttons[6] = new JButton("JTitledBorder (2)");
    buttons[6].setBorder(new JTitledBorder(this,new JLineBorder(Color.black,3),
                                           "Title2"));

    buttons[7] = new JButton("JTitledBorder (3)");
    buttons[7].setBorder(new JTitledBorder(this,
                                           new JLineBorder(Color.darkGray, 3),
                                           "Title3", 
                                           JTitledBorder.RIGHT,
                                           JTitledBorder.ABOVE_TOP,
                                           new Font("SanSerif", 
                                                    Font.ITALIC, 14),
                                           Color.blue));

    // Set a layout manager for this panel, create a font for the components
    // set the font on each component, and add the component to the panel
    this.setLayout(new GridLayout(4, 2, 15, 15));
    Font f = new Font("SansSerif", Font.BOLD, 12);
    for(int i = 0; i < buttons.length; i++) {
      buttons[i].setFont(f);
      this.add(buttons[i]);
    }
  }
}
