While testing some real-time simulation code which uses a Swingworker I noticed my GUI always seems to run at 30 fps, no more, no less. I update the GUI everytime the user i
It turns out SwingWorker
posts instances of Runnable
to the EventQueue
using a javax.swing.Timer
with exactly that DELAY
.
private static class DoSubmitAccumulativeRunnable
extends AccumulativeRunnable<Runnable> implements ActionListener {
private final static int DELAY = (int) (1000 / 30);
...
}
You can get a higher frame rate, but not with javax.swing.SwingWorker
. You can build SwingWorker
from source, but eventually you saturate the thread with instances of Runnable
. One alternative is to run the model flat out and sample it periodically, as shown here.