title: Obtaining focus on a JPanel
body: <p>I have a <code>JPanel</code> inside a <code>JFrame</code>. I have registered a <code>KeyListener</code>, based on which I want to update the <code>JPanel</code>. The problem I am having is that I cannot get the focus on the <code>JPanel</code> and therefore my <code>KeyListener</code> won't work. I already know that the <code>KeyListener</code> is functional because I registered it with the <code>JFrame</code> and it worked fine. My code goes something like this at the moment:</p>
  
  <pre><code>myFrame.setFocusable(false);
  myPanel.setFocusable(true);
  myPanel.addKeyListener(myKL);
  myFrame.add(myPanel);
  </code></pre>
  
  <p>Has anyone encountered a problem like this before? Is there something I am missing in regards to this?</p>
  
  <p>P.S.: I do not have any components inside the <code>JPanel</code> I just draw an Image on the background, so I need the focus to be on the JPanel itself and not on something inside it.</p>