开发者

How to get custom defined gif in Java Swing while a task is in Progress

开发者 https://www.devze.com 2023-01-26 04:35 出处:网络
I need to put a rotating Waiting.gif image indicating task is in progress when I call a EJB method开发者_JAVA技巧 from my java Swing class.If EDT is \"totally\" blocked by your EJB method such that no

I need to put a rotating Waiting.gif image indicating task is in progress when I call a EJB method开发者_JAVA技巧 from my java Swing class.


If EDT is "totally" blocked by your EJB method such that no event processing occurs at all, then there's nothing you can do. In that case you have to move the EJB call to a SwingWorker.

If EDT is only "partially" blocked, for example by a modal dialog, then you can add an ImageObserver to your ImageIcon, and repaint the icon in imageUpdate (e.g. call paintImmediately if your icon is set on a JLabel).


Take a look at JXBusyLabel, it has some defaults and support for BusyPainter as well that controls the image/animation you want to be displayed. Check here for a basic tutorial.

0

精彩评论

暂无评论...
验证码 换一张
取 消