1 30 31 package com.jgoodies.animation; 32 33 import java.util.LinkedList ; 34 import java.util.List ; 35 import java.util.StringTokenizer ; 36 37 import javax.swing.SwingUtilities ; 38 39 46 public final class AnimationUtils { 47 48 49 private AnimationUtils() { 50 } 52 53 54 60 public static void invokeOnStop(Animation animation, Runnable runnable) { 61 animation.addAnimationListener(new StopListener(runnable)); 62 } 63 64 65 73 public static String [] splitTexts(String separatedTexts) { 74 StringTokenizer tokenizer = new StringTokenizer (separatedTexts, "|"); 75 List texts = new LinkedList (); 76 while (tokenizer.hasMoreTokens()) { 77 texts.add(tokenizer.nextToken()); 78 } 79 return (String []) texts.toArray(new String [texts.size()]); 80 } 81 82 83 85 private static class StopListener extends AnimationAdapter { 87 88 private final Runnable runnable; 89 90 private StopListener(Runnable runnable) { 91 this.runnable = runnable; 92 } 93 94 public void animationStopped(AnimationEvent e) { 95 SwingUtilities.invokeLater(runnable); 96 } 97 } 98 99 } | Popular Tags |