I use Ryan solution too with image rendering instead of calling repaint.
One remark : the Graphic class display looks better than the Graphic2D
class. I have superposition and refreshing, and in my case i got this.
Thanks Ryan !
Le dimanche 25 juillet 2010 18:22:45 UTC+2, Mate Toth a écrit :
>
Thx guys!
I used double-buffering like in Ryan's code and it worked like a
charm!
M
On Jul 25, 4:01 am, Ryan Sattler wrote:
> I've been working on a game with Clojure/Swing lately and the simplest
> way to avoid flashing is to draw to a bufferedImage first, then draw
> that bufferedImage all at
On Sun, Jul 25, 2010 at 12:55 PM, Ryan Twitchell wrote:
> You'd be best served overriding the JPanel's paint or paintComponent
> method (I'm fuzzy on the difference), and then calling repaint
> periodically (at your desired frame rate). IIRC, repaint is safe to
> call from any thread, and it will
On Sat, Jul 24, 2010 at 3:11 PM, Mate Toth wrote:
> Hi,
>
> my problem is that during execution my presentation java applet is
> flashing. There are many components which paint to a JPanel using it's
> Graphics (.getGraphics). I think maybe the problem is that I don't
> have any "paint everything
HI,
You'd be best served overriding the JPanel's paint or paintComponent
method (I'm fuzzy on the difference), and then calling repaint
periodically (at your desired frame rate). IIRC, repaint is safe to
call from any thread, and it will cause the paint methods to be called
in the swing thread.
I've been working on a game with Clojure/Swing lately and the simplest
way to avoid flashing is to draw to a bufferedImage first, then draw
that bufferedImage all at once. This means that parts of the screen
that don't change won't be briefly overwritten by the background
color, avoiding flashing.
I see 2 things:
1) It's best to explicitly start your Swing UI on Swing's event dispatch
thread. The java code to do this is:
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new App(); // OR whatever you're started UI code is
}
It is probably happening because a bare bones JPanel is a white canvas
every time swing paints it, it paints a white canvas than your
routines paint over that giving you the flashing behavior, right way
to paint on a JPanel is to extend it using proxy and overwrite
paintComponent method, this is th
Hi,
my problem is that during execution my presentation java applet is
flashing. There are many components which paint to a JPanel using it's
Graphics (.getGraphics). I think maybe the problem is that I don't
have any "paint everything now" routine..(I don't know which Java
routine to use, how I h