title: How can I force Jpanel to immediately repaint in Java?
body: <p>Here is my code</p>
  
  <pre><code>boolean boo = true;
  
  ItemListener itemListener = new ItemListener() {
      public void itemStateChanged(ItemEvent event) {
          boo= false;         
          aSwingObj.repaint();
          boo = true;
       }
  }
  </code></pre>
  
  <p>I want the repaint() method to run while boo is set to false, before it becomes true .</p>
  
  <p>The problem is that repaint() function is only executed after the variable boo has been set to true again. I have tried other methods like revalidate(), validate() but it didn't work. How should I fix my code? </p>