server_crash 64 Postaholic

This class is suppose to create a JPanel with a bufferedimage to draw on..I instanstiate this class from the main driver class, and it shows up fine, but I can't draw anything on the image, or even set the background color of the jpanel.

Here is the class, see if anything is wrong please:

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

public class ImagePlotter extends JPanel
{
	BufferedImage cartisianImage;
	Graphics2D g2d;
	
	public ImagePlotter()
	{
		setPreferredSize(new Dimension(200,200));
		setBackground(Color.white);
	}
	public void paintComponent(Graphics g)
	{
		g2d = (Graphics2D)g;
		
		int width = 300;
		int height = 300;
		
		cartisianImage = (BufferedImage)(this.createImage(width,height));
		Graphics2D gc = cartisianImage.createGraphics();
		
		gc.setColor(Color.green);
		 Rectangle2D.Double theRectangle = 
            new Rectangle2D.Double(
                                       0,0,200,200);

		gc.draw(theRectangle);
		
		super.paintComponent(gc);
	}
	
	public void drawPolynomialLine(int[] xPoints, int[] yPoints, int count)
	{
		g2d.drawPolyline(xPoints,yPoints, count);
		repaintComponent();
	}
	
	public void repaintComponent()
	{
		repaint();
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.