What is the usual way to implement animations (e.g. a composite with a changing position, in SWT) so that they look equally fast on all machines?
The naive approach would be to use timestamps, to stop the time untill the next animation step.
Is there a more professional way?
The only approach is using timestamps; the naïve and professional approaches differ in how they are used.
The naïve approach uses a thread and
Thread.sleep(). The professional approach uses timers to run code at certain intervals and let the timer decide how to handle delays and jitter.You can learn more about timers, look at the classes
TimerandTimerTask.java.util.Timer.scheduleAtFixedRate(TimerTask, Date, long)should be a good start. Just be aware that the code is executed in a new thread, so you need to use the usual tools to inject events into the UI thread’s queue.