テキストエリアへの背景描画

import java.awt.*;
import java.awt.event.*;

public class Test {
	public static void main (String[] args)
	{
		Win win = new Win("Test Window", "Test Data");
	}
}

/*******************/
/* クラスWinの定義 */
/*******************/
class Win extends Frame {

	TextArea tx;

	/******************/
	/* コンストラクタ */
	/******************/
	Win (String name, String data)
	{
					// Frameクラスのコンストラクタ(Windowのタイトルを引き渡す)
		super(name);
						// テキストエリアの追加
		setLayout(new BorderLayout(5, 10));
		Font f = new Font("MS 明朝", Font.BOLD, 20);
		setFont(f);
		tx = new TextArea("Text Area", 5, 20);
		add(tx, BorderLayout.CENTER);
						// Windowの大きさ
		setSize(300, 200);
						// ウィンドウを表示
		setVisible(true);
						// テキストエリアの背景の描画
		Graphics g = tx.getGraphics();
		g.setColor(Color.blue);
		int i1, x = 20, y = 0;
		for (i1 = 0; i1 < 8; i1++) {
			g.drawLine(x, y, x, y+80);
			x += 20;
		}
		g.dispose();
					// イベントアダプタ
		addWindowListener(new WinEnd());
	}

	/******************************/
	/* 上,左,下,右の余白の設定 */
	/******************************/
	public Insets getInsets()
	{
		return new Insets(50, 50, 50, 50);
	}

	/************/
	/* 終了処理 */
	/************/
	class WinEnd extends WindowAdapter
	{
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	}
}