Swing/AnimatedTrayIcon のバックアップの現在との差分(No.20)
- category: swing folder: AnimatedTrayIcon title: TrayIconのアニメーション tags: [SystemTray, Icon, Animation] author: aterai pubdate: 2007-02-05T02:07:43+09:00 description: SystemTrayに追加したトレイアイコンをアニメーションさせます。 image:
概要
SystemTray
に追加したトレイアイコンをアニメーションさせます。
Screenshot
Advertisement
サンプルコード
TrayIcon icon = new TrayIcon(imglist[0], "TRAY", popup);
animator = new Timer(100, new ActionListener() {
private int idx = 0;
@Override public void actionPerformed(ActionEvent e) {
icon.setImage(imglist[idx]);
idx = (idx + 1) % imglist.length;
}
});
View in GitHub: Java, Kotlin解説
上記のサンプルでは、16x16
の画像を3
パターン用意しこれをJDK 6
で追加されたTrayIcon#setImage(Image)
メソッドを使って切り替えることでトレイアイコンのアニメーションを行っています。
-
16x16
の画像を3
パターン用意 -
JDK 6
で追加されたTrayIcon#setImage(Image)
メソッドを使用して、この3
パターンの画像を切り替えることでトレイアイコンのアニメーションを実行