Problem: Mulitple panels, one Graphics2d object?!?!

Help!

My application contains one main JPanel, called DrawingPanel. DrawingPanel contains many different Graphics2D objects that it periodically repaints and redraws. When a user clicks on one of these objects, the listener pops up a different JPanel (a list of these new Panels is a member variable of DrawingPanel). In this JPanel I want to draw some new Graphics2D objects. The problem is that when I call paint or paintComponent in the new JPanel (i've tried both) the Graphics2D object contains all the objects from DrawingPanel also. How do I get rid of this extra garbage? I've tried using the dispose function after painting the graphics in both places, but this doesn't work...ideas?

(sorry, for the cross post to java swing if anyone noticed...I'm desperate and figured that maybe I put this in the wrong forum originally...thanks)

[871 byte] By [JessicaUVA] at [2007-9-26 2:32:51]
# 1

your query is difficult to understand, if ur problem is related to painting to the specific panel try

painting

component.paintComponent()

or if ur panels are a differnet classes then try to override the paint method in each place.

and if u do not want a paint method at all

then create a graphics object with

component.getGraphics() method and dispose ur

graphics object inside finalize() method.

b_babu at 2007-6-29 9:55:02 > top of Java-index,Security,Cryptography...