Java by API/org.eclipse.swt.custom/BusyIndicator
BusyIndicator.showWhile(Display com, Runnable run)
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell shell = new Shell(d);
shell.setSize(250, 200);
final String RUN = "Press to Run";
final String IS_RUNNING = "Running...";
shell.setLayout(new FillLayout());
final Button button = new Button(shell, SWT.PUSH);
button.setText(RUN);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
button.setText(IS_RUNNING);
BusyIndicator.showWhile(button.getDisplay(), new SleepThread(1000));
button.setText(RUN);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
class SleepThread extends Thread {
private long ms;
public SleepThread(long ms) {
this.ms = ms;
}
public void run() {
try {
sleep(ms);
} catch (InterruptedException e) {}
}
}