title: Swing, how to properly update the UI
body: <p>What is the right way to update the UI after doing some operations on Swing?</p>
  
  <p>For example, after clicking a button, a method is called that may be almost instant or take some seconds. In fact, all the applicaton logic is done remotely through a web service, so it's normal to wait a little bit for the application to respond.</p>
  
  <p>My eventhandler for a button may look like these:</p>
  
  <pre><code>myButton.addActionListener(new java.awt.event.ActionListener() {
     public void actionPerformed(java.awt.event.ActionEvent evt) {
         //callWebService();
         //do stuff
         //updateUI(); // &lt;----- repaint? revalidate? what?
     }
  });
  </code></pre>
  
  <p>My current implementation calls the updateUI method which internally call validate() and repaint() to the parent component that holds the UI. This works, but sometimes I can see the screen flickering. Am I doing it wrong? Is there a better way to do it?</p>