title: "GUI while loop"
body: <p>Okay, I have a code that looks like this:</p>
  
  <pre><code>public class Test
  {   
  
  private JPanel dummy;
  
  public checker()
  {
      dummy = new JPanel();
      dummy.setVisible(false);
  
      dummy.addComponentListener(new ComponentAdapter()
      {
          @Override
          public void componentShown(ComponentEvent arg0)
          {
              dummy.setVisible(false);
              runCheck();
          }           
      });
  
      runCheck();
  }
  
  
  private void runCheck()
  {
      if (a)
      {
          //do something
          dummy.setVisible(true);
      }
  }
  
  }
  </code></pre>
  
  <p>This will create a dummy JPanel and add a component adapter that will fire each time dummy is set to be visible. It works like a while loop, only it makes sure that GUI is updated before it goes into another cycle.</p>
  
  <p>But I need method <code>checker()</code> to return a value once the cycle is broken. </p>
  
  <p>NOTE:
  This is symplified version of code, I cannot check for condition <code>a</code>, that is not a solution.</p>