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