title: Can't focus on JTextField in JDialog
body: <p>I'm trying to focus on a JTextField in a JDialog; I've tried all the suggestions in <a href="http://tips4java.wordpress.com/2010/03/14/dialog-focus/" rel="nofollow">this link</a> after poking around for similar questions, but none of the suggestions worked.</p>
  
  <p>The component I'm trying to focus on is created in a class called "InputTaskWindow", and I'm trying to create a dialog from a class called "MainWindow". Here's where the issue is (This is within "MainWindow"):</p>
  
  <pre><code>public  class NewTask extends AbstractAction {
  
  JList mTaskList;
  JTextArea mDetailsTextArea;
  
  public NewTask (JList tl, JTextArea dta){
      mTaskList = tl;
      mDetailsTextArea = dta;
  }
  
  public void actionPerformed(ActionEvent e) {
      int option = 0;
      InputTaskWindow inputTaskWindow = new InputTaskWindow();
      JOptionPane optionPane = new JOptionPane(inputTaskWindow.createComponents(), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
  
      JDialog dialog = optionPane.createDialog("New Task");
  
      dialog.setSize(200, 200);
  
      dialog.pack();
  
      ((JTextField) inputTaskWindow.getComponent(inputTaskWindow.NAMETF)).requestFocus();
  
      dialog.setVisible(true);
  
      if (optionPane.getValue() != null){
          option = (Integer)optionPane.getValue();
      }
  
      if (option == JOptionPane.OK_OPTION){
          Task t = inputTaskWindow.getTask();
          activeDay.addTask(t);
      }
  
      populateLists(mTaskList);
  }
  </code></pre>
  
  <p>I put the JTextField I'm trying to access in an array of JComponents in the GUI class; I've accessed other components using the getComponents() method, so I know that's pointing to the correct thing.</p>
  
  <p>I've tried requestFocus(), requestFocusInWindow(), adding an ancestorListener in the NewTask class, and adding an ancestorListener upon the creation of the JTextField in InputTaskWindow (in both cases I'm adding it to the JTextField and using the RequestFocusListener class described in the link). Any help would be much appreciated.</p>