Well, as for a simple progress wheel that doesn't show the actual progress (just that your application is doing something), I'd recommend a simple animated image (generate one at http://www.ajaxload.info/ for example).
If an animated image/gif is not an option:
A simple solution would be creating several images and replace them in a circular fashion. I used this recently, basically you make a timer that calls itself:
Timer updateAnim = new Timer() {
@Override
public void run() {
currentImage = (currentImage + 1) % NO_IMAGES;
setVisibilities();
this.schedule(UPDATE_TICK);
}
};
private void setVisibilities() {
img1.setVisible(false);
img2.setVisible(false);
switch (currentImage) {
case 0:
img1.setVisible(true);
break;
case 1:
img2.setVisible(true);
break;
}
}
setVisibilities()
just sets the current image to visible, all the other to invisible. I experienced this to be faster than switching the image URL (using only one Image, calling img.setURL(String url);
).
Now you just call updateAnim.schedule(UPDATE_TICK);
and it will run.
I guess the fastest (because the browser can optimize that) would be the use of a CSS animation (creating one image and rotating it), but probably also the most complex (haven't used that much, so might as well be that it's actually more simple than I think ;). Have a look at this post about CSS rotation animations.
If you want to make a real progress bar (that actually shows progress), you need a callback that gets called on progress. Just update your images / CSS transitions in this progress callback.