Extras: FlatAnimatedLafChange: made animated Laf change transition smoother

This commit is contained in:
Karl Tauber
2021-09-04 13:19:12 +02:00
parent 78a9cc1d0c
commit 253df9325d

View File

@@ -19,6 +19,7 @@ package com.formdev.flatlaf.extras;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Toolkit;
import java.awt.Window; import java.awt.Window;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import java.util.Map; import java.util.Map;
@@ -51,9 +52,9 @@ public class FlatAnimatedLafChange
public static int duration = 160; public static int duration = 160;
/** /**
* The resolution of the animation in milliseconds. Default is 40 ms. * The resolution of the animation in milliseconds. Default is 30 ms.
*/ */
public static int resolution = 40; public static int resolution = 30;
private static Animator animator; private static Animator animator;
private static final Map<JLayeredPane, JComponent> oldUIsnapshots = new WeakHashMap<>(); private static final Map<JLayeredPane, JComponent> oldUIsnapshots = new WeakHashMap<>();
@@ -158,6 +159,8 @@ public class FlatAnimatedLafChange
if( e.getKey().isShowing() ) if( e.getKey().isShowing() )
e.getValue().repaint(); e.getValue().repaint();
} }
Toolkit.getDefaultToolkit().sync();
}, () -> { }, () -> {
hideSnapshot(); hideSnapshot();
animator = null; animator = null;