A solution that may not be as pretty but will probably work is to disable 
double buffering on your component (or turning off your opaqueness).  The 
reason your component draws correctly when resized but not when updating is 
what Chet mentioned: you do not redraw your background.

Turning off double buffering should--to the very short extent of my knowledge 
there--force a complete redraw of your component, from scratch, each time it is 
painted.  It's kind of like pulling in the pneumatics to hang your painting, 
but it has a short of working.

Turning off opaqueness may work simply because you're telling Swing that your 
component is [i]not[/i] taking responsibility for filling its own space.  It 
does not make your component transparent as such, but broadcasts that it will 
neglect to paint some parts of its own background and, as such, that Swing 
shouldn't make assumptions about repainting areas.

Personally, my preference goes to turning off opaqueness.  You may either 
override [i]isOpaque()[/i] to return false, call [i]setOpaque(false)[/i] in 
your constructor, or derive from JComponent instead of JPanel--at least, I 
believe JComponent is not opaque; I draw graphs just like you do, but on 
JComponent rather than JPanel, and I've never had these issues for long 
(usually an oversight on my end).


On that side-topic caching thing... 15 minutes?  Even if you're confident your 
users are zooming in and out regularly, I doubt it'll hurt much to draw into an 
image and then overlay the grid rather than have Java repaint it each time.  
But that's just performance sugar at the moment, really.
[Message sent by forum member 'tarbo' (tarbo)]

http://forums.java.net/jive/thread.jspa?messageID=208283

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to