1

I am making an application on swing. When I tried to fetch record from database which has more than thousands rows. It takes few time to retrieve. It may make bored to my client. So I want to display message like

Loading please wait... 

If request takes more than 5 minutes to get response at any request I want to display like above message. Please help me.. Thanks

Yubaraj
  • 3,800
  • 7
  • 39
  • 57
  • Please have a look at this [example](http://stackoverflow.com/a/16938228/1057230) by @MadProgrammer, this might can give a slight idea how to go about achieving what you so desire :-) – nIcE cOw Aug 15 '13 at 06:17
  • 1
    OK.I will try to do.. – Yubaraj Aug 15 '13 at 06:33

2 Answers2

2

Start by taking a look through Concurrency In Swing...

Probably the easiest solution would be use a SwingWorker, which will allow to execute the request in a background thread, but provides a number of methods to sync the updates back to the UI.

For example...

SwingWorker requestWorker = new SwingWorker<Object, Object>() {
    protected Object doInBackground() throws Exception{
        // Make your request
        // Process your request
        // You can use setProgress if you know how many values you have...
        // (You will need to use a property listener to monitor
        //  these changes ;))
        // You can also use publish to push updates back to the UI
        return null;
    }

    protected void done() {
        // Remove the "wait" notification...
    }
}
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
2

You can use the JXBusyLabel in JavaFX. Simply paint the label over glasspane. This link might help you.

Vighanesh Gursale
  • 921
  • 5
  • 15
  • 31