// RepaintJPanel.java
// Panel for drawing a rectangle on itself
import java.awt.*;
import javax.swing.*;

public class RepaintJPanel extends JPanel {
	int width, height;

	public void passDim( int wid, int hgt ) {
		width = wid;
		height = hgt;
		repaint( );	// calls paintComponent
	}

	public void update( Graphics g ) {
		paintComponent( g );
	}

	public void paintComponent( Graphics g ) {
		// call super version
		super.paintComponent( g );		

		g.setColor( Color.red );
		g.fillRect( 50, 100, width, height );
	}
}