I am new to Java, newer to swing. In a project I am trying to dispose a frame when a task is completed. I have a static boolean variable JobDone initially set to false in the class (FinalOutput) where the main task is performed and after the task gets completed it is set to true. I searched about checking something periodically in java and I found it can be achieved through Timer. Now based on this variable I'm trying to dispose the frame using a Timer.
Below is what I tried: This code in main function of the frame (ProgressBarForm) to be disposed.
                ProgressBarForm obj = new ProgressBarForm(); 
                Timer t = new Timer();
                t.scheduleAtFixedRate(new TimerTask(){
                @Override
                public void run(){ 
                    if(FinalOutput.isJobDone())
                        obj.dispose();
                }}, 100, 100);
But the frame is not getting disposed after the job gets completed. Kindly help me through this. Thanks in advance.
