diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeExpansionAnimationListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeExpansionAnimationListener.java index 8138ffd1..506791d9 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeExpansionAnimationListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeExpansionAnimationListener.java @@ -42,6 +42,15 @@ public class DarkTreeExpansionAnimationListener implements TreeExpansionListener tree.addTreeExpansionListener(this); } + public void install() { + this.tree.addTreeExpansionListener(this); + } + + public void uninstall() { + animator.dispose(); + this.tree.removeTreeExpansionListener(this); + } + @Override public void treeExpanded(final TreeExpansionEvent event) { startAnimation(event.getPath()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java index 667595b2..cbcc36d5 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java @@ -168,7 +168,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C selectionListener = createMouseSelectionListener(); tree.addMouseListener(selectionListener); this.treeExpansionAnimationListener = createExpansionAnimationListener(); - tree.addTreeExpansionListener(treeExpansionAnimationListener); + treeExpansionAnimationListener.install(); } protected DarkTreeExpansionAnimationListener createExpansionAnimationListener() { @@ -258,7 +258,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C tree.removeMouseListener(selectionListener); selectionListener = null; tree.removePropertyChangeListener(this); - tree.removeTreeExpansionListener(treeExpansionAnimationListener); + treeExpansionAnimationListener.uninstall(); treeExpansionAnimationListener = null; }