I am trying to execute a program which takes around 6-7 seconds to execute after displaying GUI for the user. Problem here is that the user has to wait for 6-7 seconds without any processing or progress notification.
So want i am trying to do is that, while the MainApp ma = new MainApp(); code executes, i want to display a gif picture for the user saying that the program is being executed. Displaying of picture code is written in
ShowProgressPic spp = new ShowProgressPic();
I have a boolean datatype variable named end which will be set to true in the last statement of MainApp() constructor. When the execution of the MainApp ma = new MainApp(); ends, i want to stop displaying the gif image.
Please help me out with this.
Thank you.
Assuming that you’re problem involves a Swing GUI, I would suggest that you use a SwingWorker to do the long-acting program execution in a background thread. Then when the thread is done, you have two or more ways of proceeding from there. You can have the SwingWorker call code in its done method to close the progress display or you can have the code that holds and executes the SwingWorker listen to the SwingWorker via a PropertyChangeListener and act when the state property is SwingWorker.StateValue.DONE.