Summary
JToolTipが表示されたとき、内部のJLabelでアイコンのアニメーションを行う方法をテストします。
Screenshot

Advertisement
Source Code Examples
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL url = cl.getResource("example/anime.gif");
JLabel l3 = new JLabel("Gif Animated ToolTip(html)");
l3.setToolTipText(String.format("<html><img src='%s'>Test3", url));
View in GitHub: Java, KotlinDescription
Timer Animated ToolTipjavax.swing.Timerを使ってアニメーションを実行するJLabelを作成してJToolTipに配置- Timerでアニメーションするアイコンを作成
JLabel l1 = new JLabel("Timer Animated ToolTip") { @Override public JToolTip createToolTip() { JToolTip tip = new AnimatedToolTip(new AnimatedLabel("")); tip.setComponent(this); return tip; } }; l1.setToolTipText(" ");
Gif Animated ToolTipAnimated GIFファイルをJLabel#setIcon(Icon)で設定したJLabelをJToolTipに配置JLabel l2 = new JLabel("Gif Animated ToolTip") { @Override public JToolTip createToolTip() { JToolTip tip = new AnimatedToolTip( new JLabel("", new ImageIcon(url), SwingConstants.LEFT)); tip.setComponent(this); return tip; } };
Gif Animated ToolTip(html)Animated GIFファイルを<html>タグを使ってsetToolTipText(...)メソッドで設定