title: Updating the JPanel in a JFrame
body: <p>I have a JFrame with a CardLayout component. I am using the CardLayout to switch between different JPanel's at different moments of the application execution. At some point I am using a SwingWorker Object to generate some XML files. In this time I want to display another JPanel in my window to tell the user to wait. On this JPanel I want to switch between 3 labels. </p>
  
  <ul>
  <li>JLabel 1 would be : "Please wait." </li>
  <li>JLabel 2 would be : "Please wait.."</li>
  <li>JLabel 3 would be : "Please wait..."</li>
  </ul>
  
  <p>Right now the code looks like this:</p>
  
  <pre><code>        ConvertersWorker.execute();
          CLayout.show(Cards, WAIT_PANEL);
  
  
          Timer t =new Timer(500, new ActionListener()
          {
              @Override
              public void actionPerformed(ActionEvent e) {
                  WaitPanel.SwitchLabels();
              }               
          });
          t.start();
  
          while (!this.finishedConverting)
          {
  
          }
          //After this im am executing other methods based on the generated XML files
  </code></pre>
  
  <p>The SwingWorker code:</p>
  
  <pre><code>SwingWorker&lt;Boolean, Void&gt; ConvertersWorker = new SwingWorker&lt;Boolean, Void&gt;() {
      public Boolean doInBackground() {
          Boolean result = RunConverters();
          return result;
      }
      public void done() {
          try {
              finishedConverting = get();
          } catch (InterruptedException ex) {
              ex.printStackTrace();
          } catch (ExecutionException ex) {
              ex.printStackTrace();
          }
      }
   } ;
  </code></pre>
  
  <p>The second JPanel is not even displayed because the JFrame blocks. It blocks because of the while loop but I don't know how to implement it differently. And also the method done() from the SwingWorker is never executed. If it were executed then the finishedConverting variable would have been set to true and the while loop would have stopped. Can anyone help me to find a better solution?</p>