Stopping a component from being cleared every frame
Hello,
I'm still struggling to convince my Swing-based applet not to paint over the background every frame. I've actually found a way of doing this, by overwriting the JPanel's update method so it only calls paintComponent, and that only calls super.paintComponent if I want it to... but this has the unfortunate side-effect that any Swing component the user interacts with is mysteriously drawn in the top-left corner as well as the correct place. What?!
See the effect in action (select 'trails' under 'history').
If nobody here's got any clever ideas to fix it (calling setDoubleBuffered(false) won't help, and nor will setOpaque(false or indeed true)), I'll give up on the idea of saving all the processing power and memory consumed by unnecessary double-buffering, and just draw to an off-screen image, but it'd be nice to avoid that...!
Cheers folks
I'm still struggling to convince my Swing-based applet not to paint over the background every frame. I've actually found a way of doing this, by overwriting the JPanel's update method so it only calls paintComponent, and that only calls super.paintComponent if I want it to... but this has the unfortunate side-effect that any Swing component the user interacts with is mysteriously drawn in the top-left corner as well as the correct place. What?!
See the effect in action (select 'trails' under 'history').
If nobody here's got any clever ideas to fix it (calling setDoubleBuffered(false) won't help, and nor will setOpaque(false or indeed true)), I'll give up on the idea of saving all the processing power and memory consumed by unnecessary double-buffering, and just draw to an off-screen image, but it'd be nice to avoid that...!
Cheers folks
