passive rendered game

What are the drawbacks of using repaint on swing components instead of using a game loop?
relative to the problems in a turn based game:
animated units, static terrain, animated menu, explosion animation, blinking stars, rain, snow(small images moving over the whole screen)
units should be 20% darker when inactive, and they stop animating.

I know
that painting and input both are passed in the awt event thread
that java2d can use software/hardware rendering

I don’t know howto update the animations, should I use a swing timer and call update using that? or use gifs and let java update them for me.
But how do you stop a animated gif?

I though about creating a swing timer and let it call repaint every second. To allow a scrolling background for example.

Passive rendering doesn’t work well at all. You don’t know when the screen is going to be rendered.

It might render the screen three times when it hasn’t changed and then not render when the screen does change.

Active rendering draws the screen as often as possible without slowing down the game logic any more than possible. Passive rendering won’t typically draw the screen as often.

Having done passive rendering in Swing (including animation…), I can confirm it doesn’t work as bad as everyone wants you to believe. I found active rendering somewhat of a headache if you want to use it for a multiplayer game (thread synchronization). I didn’t notice much of a difference between active and passive rendering in Swing, but I am pretty sure people will disagree with me and tell you I am a bad coder.

Anyhow, I advice you go OpenGL if rendering is a concern, otherwise, passive rendering in Swing (done correctly) will probably just be fine?

Judge for yourself (passive rendering in Swing): http://www.tiicoon.com/webstart/City.jnlp

I can’t see a reason why you wouldn’t have control over that. You might not have control over some additional requests generated from the window but you can always cache the whole screen which swing already does afaik.

You can render to an image that will eventually be drawn to the screen whenever you want, but you can’t make it actually be drawn to the screen. When you call repaint, it just suggests that the screen be repainted when the AWT Event Thread has time. You could just call paint, but that would really be mixing active and passive rendering. I have a feeling that might be a bad idea.

Swing does cache the whole screen for you. In fact, it has a back buffer for every single Swing Component, which seems excessively wasteful.

I was a bit warped there - that was not the caching I meant, doesn’t matter anyways

Profiling shows that ‘excessively wasteful’ mismatches with what actually is going on.

repaint will cause a paint there are just no guaranties at what point in time or before what death-line. Unless you use a real-time OS even active rendering doesn’t give you either. Repaint does ‘guaranty’ that there will be a repaint, the task doesn’t get dropped no matter how stressed the EDT is.

Mixing active and passive rending will work just fine - why wouldn’t it passive rendering is basically a optimised version of active rendering. filthy rich clients guys probably used something similar with there glass layer approach. - or they do fire off a zilion events I don’t know.