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.
精彩评论