title: Best practice for setting focus to a Swing control in a JPanel
body: <p>One school of thought says to add a window listener and set focus when the windowOpened event fires: </p>
  
  <pre><code>addWindowListener(new WindowAdapter(){ 
    public void windowOpened( WindowEvent e){ 
      txtMessage.requestFocus();
    } 
  });
  </code></pre>
  
  <p>The other school of thought says to use the SwingUtilities.invokeLater method to set focus in a separate thread.</p>
  
  <pre><code>SwingUtilities.invokeLater(new Runnable()
  {
    public void run() {
      field.requestFocus();
    }
  });
  </code></pre>
  
  <p>Can anyone tell me which is best practice or when you would choose one over the other?
  When using the threaded solution, is it possible for the thread to get lost and focus never set?</p>