void () { if (myStartMeasureTime.get() > 0) { myMeasureDuration.set(System.nanoTime() - myStartMeasureTime.get()); myFps.set((int)(myFrameCount.get() / ((float)myMeasureDuration.get() / 1000000000))); } myFrameCount.set(0); myStartMeasureTime.set(System.nanoTime()); // during the measurement the component can be repainted partially in which case // the FPS bar may run out of the clip, so here we request repaint once per a tick requestFpsBarRepaint(); }