Jump to content
  • Advertisement
Sign in to follow this  
Kaze

[java] java applicaion drawing?

This topic is 4411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there any way to create a permanent drawing handle to a component within a swing application, basically i want create a animation within a app but not use repaint as it seems to redraw everything and cause a lot of overhead, i tried this and only got 12 fps, with awt i got over 100 but id rather not use awt

Share this post


Link to post
Share on other sites
Advertisement
You can invoke update/repaint methods on individual components, but the performance depends on how they're ordered and whether they have transparent backgrounds, etc..

You could try using a parametised (Not sure that's even a worg :) ) version of repaint/update to define a "dirty" rectangle. This means only the specified rectangle should get redrawn.

Share this post


Link to post
Share on other sites
Maybe you want to create an offscreen image to draw all your stuff, and then simply show the image. You can also use double buffering with buffer strategy... Search a bit on google and you're sure to find out what you need.

Share this post


Link to post
Share on other sites
im not sure i explained the problem very well, basicly calling the repaint(); in swing is very slow so i was wondering if there was a way to draw a animation without calling it. I suspect the cause of the slowness is because calling repaint(); repaints everything in swing as it is slow even when very little drawing is done and the same application ran much faster in awt

Share this post


Link to post
Share on other sites
There is a tutorial for fullscreen exclusive mode API.

http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

This shows what you need to do to avoid using repaint. You don't have to use fullscreen mode to use this method either. It is known as active rendering. After reading this tutorial, you can do a search on active rendering in Java to see if you can find more information. Using repaint is known as passive rendering.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!