Swing/DisableAnimatedGif のバックアップ(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- Swing/DisableAnimatedGif へ行く。
- 1 (2013-02-25 (月) 00:50:43)
- 2 (2013-03-18 (月) 03:34:51)
- 3 (2015-01-29 (木) 15:40:54)
- 4 (2016-05-31 (火) 14:34:33)
- 5 (2017-09-01 (金) 17:42:18)
- 6 (2018-02-22 (木) 14:07:32)
- 7 (2018-10-15 (月) 13:20:21)
- 8 (2020-10-16 (金) 19:14:04)
- 9 (2022-08-07 (日) 00:15:52)
- 10 (2025-01-03 (金) 08:57:02)
- 11 (2025-01-03 (金) 09:01:23)
- 12 (2025-01-03 (金) 09:02:38)
- 13 (2025-01-03 (金) 09:03:21)
- 14 (2025-01-03 (金) 09:04:02)
- 15 (2025-06-19 (木) 12:41:37)
- 16 (2025-06-19 (木) 12:43:47)
TITLE:JLabelに表示したAnimated Gifのアニメーションを停止する
Posted by aterai at 2013-02-25
JLabelに表示したAnimated Gifのアニメーションを停止する
`JLabel
に表示した
Animated Gif
`のアニメーションを停止します。
- &jnlp;
- &jar;
- &zip;
サンプルコード
JLabel label2 = new JLabel() {
@Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
if(!isEnabled()) {
infoflags &= ~FRAMEBITS;
}
return super.imageUpdate(img, infoflags, x, y, w, h);
}
};
View in GitHub: Java, Kotlin解説
上記のサンプルでは、`JLabel
が
Enabled
`でない場合にアニメーションを停止するよう設定しています。
- `
Default
`- デフォルトの`
JLabel
では、
JLabel#setEnabled(false);
`としてもアニメーションは停止しない
- デフォルトの`
- `
Override imageUpdate(...)
`- `
JLabel#imageUpdate(...)
の
infoflags
から
FRAMEBITS
`フラグを落とすことでアニメーションを停止 - `
JLabel
`がリサイズされると?、コマが進んでしまう
- `
- `
setDisabledIcon
`- 別途用意した静止画像を使って、JLabel#setDisabledIcon(...)を設定
- `
GrayFilter.createDisabledImage(Image)
`でアイコンをグレースケール化