Harish
Harish

Reputation: 3483

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

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

Upvotes: 1

Views: 718

Answers (2)

Geoffrey Zheng
Geoffrey Zheng

Reputation: 6640

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).

Upvotes: 1

Faisal Feroz
Faisal Feroz

Reputation: 12785

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.

Upvotes: 1

Related Questions