mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 23:37:13 -06:00
Animator: reuse timer instance
(cherry picked from commit 0888fd8fb5d18c36886bf958ac5a5e44bf75618d)
This commit is contained in:
@@ -184,14 +184,17 @@ public class Animator
|
|||||||
timeToStop = false;
|
timeToStop = false;
|
||||||
startTime = System.nanoTime() / 1000000;
|
startTime = System.nanoTime() / 1000000;
|
||||||
|
|
||||||
timer = new Timer( resolution, e -> {
|
if( timer == null ) {
|
||||||
if( !hasBegun ) {
|
timer = new Timer( resolution, e -> {
|
||||||
begin();
|
if( !hasBegun ) {
|
||||||
hasBegun = true;
|
begin();
|
||||||
}
|
hasBegun = true;
|
||||||
|
}
|
||||||
|
|
||||||
timingEvent( getTimingFraction() );
|
timingEvent( getTimingFraction() );
|
||||||
} );
|
} );
|
||||||
|
} else
|
||||||
|
timer.setDelay( resolution );
|
||||||
timer.setInitialDelay( 0 );
|
timer.setInitialDelay( 0 );
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
@@ -213,10 +216,8 @@ public class Animator
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void stop( boolean cancel ) {
|
private void stop( boolean cancel ) {
|
||||||
if( timer != null ) {
|
if( timer != null )
|
||||||
timer.stop();
|
timer.stop();
|
||||||
timer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !cancel )
|
if( !cancel )
|
||||||
end();
|
end();
|
||||||
|
|||||||
Reference in New Issue
Block a user