title: Trouble getting Input Focus in JFrame(s)
body: <p>Here's the (simplified) JPanel class:</p>
  
  <pre><code>import java.awt.Graphics;
  import javax.swing.JPanel;
  
  
  @SuppressWarnings("serial")
  public class Preface extends JPanel{
  
  
    public Preface(){
      this.addKeyListener(new Controls());
      this.requestFocusInWindow();
      System.out.println(this.hasFocus());//false
      this.repaint();
    }
  
    public void paintComponent(Graphics g){
      super.paintComponent(g); 
  
      g.drawImage(Tetris.getTexture("PrefacePoster.jpg"), 0, 0, 420, 556, null);
    }
  
  }
  </code></pre>
  
  <p>I was having problems getting key events to work, and realized that my panels aren't getting the input focus to begin with, and thus not generating any KeyEvents.</p>
  
  <p>I've tried grabFocus(), requestFocusInWindow(), requestFocus(), etc., yet hasFocus() always returns false. </p>
  
  <p>Why aren't my JPanels gaining input focus? Is there some way I can force them to?</p>