I'm new here, so I apologize in advance if this is irrelevant or obviously answered in another thread.
I've been working on a 2D gravity simulator, and I've found that when I run the code on my laptop (which is reasonably fast), it goes at the speed that I want it to. However, when I run the code on my PC (which is slow), I find that it goes at about half the speed that I want it to.
The physics for the game is done inside the paint() method of JComponent, which is indirectly called by javax.swing.Timer every 10 milliseconds.
My question is this: Is there any way to animate with Graphics2D so that the animation speed is constant, no matter how fast the computer is? Or, if I'm using the wrong classes for animation, what is a good alternative for what I'm trying to do?