FileDocCategorySizeDatePackage
PaintComponent.javaAPI DocExample383Sat Apr 21 15:44:02 BST 2001None

PaintComponent.java

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

public class PaintComponent extends JPanel {
	int rectX = 20, rectY = 30;
	int rectWidth = 50, rectHeight = 50;

	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.setColor(Color.red);
		g.fillRect(rectX, rectY, rectWidth, rectHeight);
	}

	public Dimension getPreferredSize() {
		return new Dimension(100, 100);
	}
}