Java 7 and Swing drawing graphics, slow?

When I switched from my Java 5 to Java 6 my Swing drawing lost like 75% of its drawing speed so I had to basically either stay with Java 5 or switch to Java 6 and convert all my code using some better graphics engine. I chose to stay with Java 1.5 for the moment.

Now with Java 1.7 out, has anyone tried it and does it work well drawing Swing or do I need to get away from Swing to get enough frame rates to make a 2D game?

It all depends on what you’re doing to draw! Maybe you’re just doing it wrong, and why use Swing for your game? Is the AWT not enough?

I am mostly drawing png’s.

did you test it on another pc? maybe there’s some incompatibily between Java 6 and your system, or something went wrong when installing

If you’re using transparency, I suspect that the problem is that your images were hardware accelerated in Java 5 but not in Java 6 for some reason.

I mean the way you are creating the images, etc. What is your approach? I.e. do you just create a buffered image?

could you run your game with java5 and java6 using the following command-line-switch:


-Dsun.java2d,trace=count

and post the output here?

lg Clemens

Maybe the cause of the difference you see between java 5 and 6 swing performance is the ‘gray-rect’ fix which stops components’ backgrounds from flashing over the screen?

This may cause less rendering to the screen , making things faster. It certainly looks as though there is less rendered since there’s no gray-rect flash every time a window is made visible. But I don’t know for sure :P.

Check this out for details: http://weblogs.java.net/blog/zixle/archive/2005/04/no_more_gray_re_1.html

That ‘fix’ for the grey rect. issue smells distinctly like yet another swing hack fix ::slight_smile:

Why do you think so?
I can’t see what’s wrong with using something which is already stored in an image and repaint it again instead of clearing the image, runing a lot of code to draw the same stuff into the image again and blit that.

In fact this is also the way Windows (well at least till XP) handled its drawing, and Windows its known to perform quite well when it comes to perceived performance of common-controls-based desktop apps.

lg Clemens

[quote]Maybe the cause of the difference you see between java 5 and 6 swing performance is the ‘gray-rect’ fix which stops components’ backgrounds from flashing over the screen?

This may cause less rendering to the screen , making things faster. It certainly looks as though there is less rendered since there’s no gray-rect flash every time a window is made visible.
[/quote]
Isn’t the OP’s problem the other way around, java6 rendering performance being degraded compared to java5?

das that the author does not reply anymore :-/