Please send questions to st10@humboldt.edu .
/**
 * TryBorder1
 * 
 * simple first example of a border (here, on a JPanel)
 * (this is simply TryJAppletPainting with a border on the painted panel)
 *
 * RECOMMENDED SIZE: 400 x 500
 *
 * modified by: Sharon M. Tuttle
 * last modified: 2-18-01
 **/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

// note --- I need to import the Swing border package!
import javax.swing.border.*;

public class TryBorder1 extends JApplet 
{
	// I do not paint on the applet itself, nor even on its
	// content pane --- I paint on a "local" extension of JPanel
	PaintPanel 		paintOnMe;

	Container		myContentPane;
	
	public void init()
	{
		myContentPane = getContentPane();

		// instantiate an instance of my "local" panel for painting on
		paintOnMe = new PaintPanel();

		// can I add the border here?
		// parameters of this version of setBorder: an anonymous
		// instance of a TitledBorder. The TitledBorder constructor
		// here is using an anonymous instance of EtchedBorder
		// followed by the desired title in String form.
		paintOnMe.setBorder(new TitledBorder(
			new EtchedBorder(), "I am a Border"));

		myContentPane.add(paintOnMe, "Center");		
	}
}

// this extension of JPanel is painted on...?
class PaintPanel extends JPanel
{
	public void paintComponent(Graphics g)
	{
		String		information;

		information = "I am a painted message";

		// NEED this! superclass of PaintPanel may need to do
		// some cleanup; this calls superclass's paintComponent()
		// method
		super.paintComponent(g);

		// paint a red message on the panel
		g.setFont(new Font("Serif", Font.ITALIC, 45));
		g.setColor(Color.red);
        	g.drawString(information, 10, 200);

		// paint a blue rectangle on the panel
		g.setColor(Color.blue);
		g.drawRect(50, 250, 300, 100);
	}
}