title: How to add a keylistener to JFrame Subclass
body: <p>I implemented all of the necessary methods and added the "implements KeyListener" and added the addKeyListener and setFocus(true) but I get no keyresponses. The JFrame includes a canvas class that I created. Here is the constructor for the window class.</p>
  
  <pre><code>    setBounds(0,0, width, height);
      setIgnoreRepaint(true);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      add(MainCanvas.Instance());
      this.getContentPane().addKeyListener(this);
      pack();
      setVisible(true);
  
      if (thread == null)
      {
          thread = new Thread(this);
      }
  
      thread.start();
  </code></pre>