title: AWT-EventQueue-0 Error with KeyListener
body: <p>I made 2 objects that moves with keylisteners. They move correctly, but in the console I receive this error every time I press a button:</p>
  
  <blockquote>
    <p>Exception in thread "AWT-EventQueue-0"
    java.lang.UnsupportedOperationException: Not supported yet.   at
    CatchMe.CatchMe.keyTyped(CatchMe.java:197)</p>
  </blockquote>
  
  <p>My code is as follows:</p>
  
  <pre><code>package CatchMe;
  
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.KeyEvent;
  import java.awt.event.KeyListener;
  import javax.swing.JFrame;
  import javax.swing.Timer;
  
  public class CatchMe extends JFrame implements ActionListener, KeyListener {
  
  private Image dbImage;
  private Graphics dbg;
  int x = 200, y = 300;
  int velX, velY;
  int velX1, velY1;
  int ScoreB1 = 0;
  int ScoreR1 = 0;
  Timer tm = new Timer(5, this);
  long startTime = System.currentTimeMillis();
  long onGoing;
  String onG;
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  int width = (int) screenSize.getWidth();
  int height = (int) screenSize.getHeight();
  int recX = (width + 100) / 2, recY = (height + 100) / 2;
  
  public CatchMe() {
      setSize(width, height);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setResizable(false);
      setVisible(true);
      tm.start();
      addKeyListener(this);
      setFocusable(true);
      setFocusTraversalKeysEnabled(false);
  }
  
  @Override
  public void paint(Graphics g) {
      dbImage = createImage(getWidth(), getHeight());
      dbg = dbImage.getGraphics();
      paintComponent(dbg);
      g.drawImage(dbImage, 0, 0, this);
  }
  
  public void paintComponent(Graphics g) {
      Rectangle r1 = new Rectangle(recX, recY, 25, 25);
      Rectangle r2 = new Rectangle(x, y, 25, 25);
      g.setColor(Color.BLUE);
      g.fillRect(r1.x, r1.y, r1.width, r1.height);
      g.setColor(Color.RED);
      g.fillRect(r2.x, r2.y, r2.width, r2.height);
      g.setColor(Color.BLACK);
      g.fillRect(0, 20, 100, 50);
      g.fillRect(100, 20, 100, 50);
      g.fillRect(200, 20, 50, 50);
      g.setColor(Color.YELLOW);
      g.drawString("Score of Blue", 5, 40);
      String ScoreB = ScoreB1 + "";
      g.drawString(ScoreB, 5, 55);
      g.drawString("Score of Red", 110, 40);
      String ScoreR = ScoreR1 + "";
      g.drawString(ScoreR, 110, 55);
      g.drawLine(95, 20, 95, 69);
      g.drawLine(200, 20, 200, 69);
      g.setColor(Color.RED);
      onGoing = (System.currentTimeMillis() - startTime) / 1000;
      onG = onGoing + "";
      g.setColor(Color.YELLOW);
      g.drawString(onG, 220, 50);
      System.out.println(onGoing);
      if (r1.intersects(r2)) {
          if (onGoing &lt;= 60 || (onGoing &gt;= 120 &amp;&amp; onGoing &lt; 180)) {
              g.setColor(Color.BLUE);
              g.drawString("Blue Caught You!", 175, 90);
              ScoreB1++;
  
          } else if (onGoing &gt;= 240) {
              if (ScoreB1 &gt; ScoreR1) {
                  Font font = new Font("Jokerman", Font.PLAIN, 50);
                  g.setColor(Color.BLUE);
                  g.drawString("BLUE WINS", 600, 400);
              } else if (ScoreB1 &lt; ScoreR1) {
                  Font font = new Font("Jokerman", Font.PLAIN, 50);
                  g.setColor(Color.RED);
                  g.drawString("RED WINS", 600, 400);
              }
          } else {
              g.setColor(Color.RED);
              g.drawString("Red Caught You!", 175, 90);
              ScoreR1++;
          }
          if (onGoing == 245) {
  
              System.exit(245);
          }
          repaint();
      }
  }
  
  @Override
  public void actionPerformed(ActionEvent e) {
      x = x + velX;
      y = y + velY;
      recY += velY1;
      recX += velX1;
      if (x &lt; 0) {
          velX = 0;
          x = 0;
      }
      if (x &gt; width - 50) {
          velX = 0;
          x = width - 50;
      }
      if (y &lt; 0) {
          velY = 0;
          y = 0;
      }
      if (y &gt; height - 40) {
          velY = 0;
          y = height - 40;
      }
      //Second square
      if (recX &lt; 0) {
          velX1 = 0;
          recX = 0;
      }
      if (recX &gt; width - 50) {
          velX1 = 0;
          recX = width - 50;
      }
      if (recY &lt; 0) {
          velY1 = 0;
          recY = 0;
      }
      if (recY &gt; height - 40) {
          velY1 = 0;
          recY = height - 40;
      }
      repaint();
  }
  
  @Override
  public void keyPressed(KeyEvent e) {
      int code = e.getKeyCode();
      if (code == KeyEvent.VK_LEFT) {
          velX = -5;
          velY = 0;
      }
      if (code == KeyEvent.VK_UP) {
          velX = 0;
          velY = -5;
      }
      if (code == KeyEvent.VK_RIGHT) {
          velX = 5;
          velY = 0;
      }
      if (code == KeyEvent.VK_DOWN) {
          velX = 0;
          velY = 5;
      }
      //Second Rect
      if (code == KeyEvent.VK_A) {
          velX1 = -5;
          velY1 = 0;
      }
      if (code == KeyEvent.VK_W) {
          velX1 = 0;
          velY1 = -5;
      }
      if (code == KeyEvent.VK_D) {
          velX1 = 5;
          velY1 = 0;
      }
      if (code == KeyEvent.VK_S) {
          velX1 = 0;
          velY1 = 5;
      }
  }
  
  @Override
  public void keyReleased(KeyEvent e) {
      velX = 0;
      velY = 0;
      velX1 = 0;
      velY1 = 0;
  }
  
  public static void main(String[] args) {
      CatchMe main = new CatchMe();
  }
  
  @Override
  public void keyTyped(KeyEvent e) {
      throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  }
  }
  </code></pre>