Thursday, February 18, 2010

How do u clear java paint panel?

Like repaint doesnt do anything, how can i delete it of all objectsHow do u clear java paint panel?
I don't know if you are 'painting' on a Canvas, a JPanel, Applet or JApplet. Are you buffering? An offscreen image is necessary if Canvas or Applet.





but, basically, you have to modify in the...


paint(Graphics g)


g.setColor( Color.white ); or getBackground();


g.fillRect (0, 0, getWidth(), getHeight());





if ur painting on a JPanel, the best place for the same idea is inside of


public void paintComponent(Graphics g)





The Object is the Canvas or JPanel. The colors are attributes.

No comments:

Post a Comment