title: Show ProgressBar with windowClosing(WindowEvent we)
body: <p>I have a JFrame. Frame was executed on EDT. A window closing event is being added to that frame using window adapter. What i need is; There is a background task that delete files generated by the application; and that task starts running when the close button of frame is being clicked. I want to show progressbar for that background tasks?</p>
  
  <pre><code>public class CloseApplication extends WindowAdapter{
  @Override
  public void windowClosing(WindowEvent we) { 
      new Thread(new Runnable() {
          @Override
          public void run() {
                  delete.deleteDirectory(a);      
                  delete.deleteDirectory(b);          
                  delete.deleteDirectory(c);            
                  delete.deleteDirectory(d); 
          }
      }).start();
  }
  </code></pre>
  
  <p>}<br>
  I tried to add progress bar to the process but it didn't displayed. I then called it in new thread; still no success. Can you give me any idea that how this can be done?</p>
  
  <p>Either way i use to call it in new thread it dont work. The reason is; background task executes in new thread and windowClosing comes to an end and close the application. If i call it without it; it makes the UI unresponsive.</p>
  
  <p>Thanks in advance.</p>