Browse Source

Tree: Ensure animation is stopped when uninstalling

Fixes #275
pull/284/head
weisj 3 years ago committed by Jannis Weis
parent
commit
c7ddc1d448
  1. 9
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeExpansionAnimationListener.java
  2. 4
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java

9
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());

4
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;
}

Loading…
Cancel
Save