wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes fps is slowing down Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "fps is slowing down" Watch "fps is slowing down" New topic
Author

fps is slowing down

Jochem Gruter
Greenhorn

Joined: Aug 16, 2011
Posts: 9
My fps is slowing down. I begin at 60 fps and after 5 minutes it is 30 and after 15 minutes it is 5 fps.



My paint is in a jPanel and I've just painted some text and rects.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Use a Swing Timer, not Thread#sleep(...) for animation. And never never run an infinite loop or sleep on the EDT.

References:
http://download.oracle.com/javase/tutorial/uiswing/misc/timer.html
http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Also, Thread.sleep(17) will sleep 17 milliseconds, not 17 seconds.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3599
    
  14

*scratches head*

It's not necessarily on the EDT right? And 17 ms seems like a decent amount to get around 60fps.

Anyway, I don't see why the OP is messing with thread priorities.
 
jQuery in Action, 2nd edition
 
subject: fps is slowing down
 
Similar Threads
doubt abt priorities in threads.......
are there webapp size restrictions?
MouseMotionEvent Performance
Set Thread priorities based on certain conditions
setPriority(int i) method of Thread