Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

Nathan deNoyelles

+ Follow
since Jul 02, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nathan deNoyelles

Hi everyone I hope someone can help me with this problem. I've been creating countless test programs and researching non stop but can't seem to find an answer.

All I'm doing is creating a ScheduledThreadPoolExecutor and scheduling it at a fixed rate of 3 milliseconds. The problem is the rate at which it executes isn't consistent. It executes for awhile at 5 milliseconds and then jumps to random spikes of 15 - 20 milliseconds and just goes crazy trying to catch up.

The problem doesn't occur inside an IDE and only occurs outside the IDE running from the command line or from a Jar. Strange huh... I created a simple test case below that's easy to compile. If you want too see the problem make sure to run it outside of an IDE through the command line.

Thank You for your help!

I'm using:
Java 7 Update 5
Windows 7
IntelliJ IDE

Been tested using:
Java 7
Windows 7, Windows 8
NetBeans IDE, IntelliJ IDE

Variation of the question posted here:
5 years ago
Hi everyone!

I've run into a curious problem, I bet its just something i'm looking over. Here's the problem, I'm using a LinearGradientPaint with two opaque colors and the very last color completely transparent.

Painting to a JPanel the drawing seems to ignore the transparent color at the end and fades to nothing with the second to last color:

However painted to a BufferedImage with the exact same code, the gradient changes to blue as it fades to nothing which I would expect:

See the difference? What could be causing this, my goal is to have the gradient look the same on the JComponent as it does on the BufferedImage.

Here's a short example that's easy to compile if you want to give it a try. To toggle between the BufferedImage and the JComponent just click anywhere in the window. Thank you for your help

5 years ago
Also seems to have the stuttering using a BufferStrategy and full screen exclusive mode, could this have something to do with Vertical Sync? Or the lack of it? Though I would expect to see the frame cut in half as the screen updates not the whole animation stutter:

5 years ago

Darryl Burke wrote:Nathan, please BeForthrightWhenCrossPostingToOtherSites

From that thread, it appears you have been digging deeper into possible causes for your problem. How about sharing your findings here?

Thanks for your reply

I didn't mention the post I made on because I've tried animations on various computers, I get the same stuttering regardless of whether hardware acceleration is present therefore I've ruled out the lack of hardware acceleration being the culprit. My question on that forum was regarding why hardware acceleration is not present on a particular machine, my question here is why my animations in general on all platforms are not fluid and how I might go about improving their performance.

I've also tried the Timer approach with no luck I still get the same stuttering every 2 or so seconds where the animation appears to jump forward and then back again. Really stumped I'm not sure what could be causing this even after a lot of research. There's got to be a way to make it stutter free or at least very close to it.

Thanks again for your help!

5 years ago
Hi everyone I'm new to the forums and I really hope I can get some help with this problem

I've been working really hard lately looking everywhere to try and figure out how to get my Java animations to flow smoothly, the main problem I have is the animation runs smooth with hiccups every 2 seconds where the animation appears to "pop" ahead of itself and then "pop" back making the animation look choppy.

Here's a short example that I created to show you guys the problem i'm having. Should be easy to compile and run if you wanna give it a try. When you run it you'll see a blue rectangle slide back and fourth on the screen, if you watch it for a bit you should notice that the rectangle seems to stop and start briefly, or "pop" ahead of itself and then jump back making the animation kinda choppy.

So my question is, what could be causing this? Any suggestions on the code or maybe some ideas on better ways to achieve a nice animation?

Thank you all for taking the time

I've also tried the following to account for the time it might take to draw a frame and compensate for the that time by sleeping less if the frame took time to draw, didn't seem to help :/

5 years ago