Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing GUI hour glass

There is a JTabbedPane In my Swing program. When user clicks on a tab, the program takes a while to get the data and process the results, then shows the results in the selected tab.

How can I display a hour glass, or something of that effect so that user knows it's processing data? Not to click on the tab again before it finishes it job.

like image 305
Frank Avatar asked Nov 27 '22 03:11

Frank


1 Answers

The simplest way is to just call setCursor on the appropriate component (probably the top-level window) with the appropriate Cursor.

component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

And then set it back when you are done.

component.setCursor(Cursor.getDefaultCursor());
like image 179
Dan Dyer Avatar answered Dec 05 '22 16:12

Dan Dyer