title: KeyListener in Java not responding
body: <p>I have to develop some easy Java app with JCheckBoxes and JButtons. In order to finish, I have to control whenever I press the number keys (0 - 9) so that the JChechBox changes its status (notSelected &lt;> selected).</p>
  
  <p>I attach my code here. I have the window done, but when I press the keys, nothing happens...</p>
  
  <p>HELP!!!</p>
  
  <pre><code>public class Window extends JFrame {
  
      public static JCheckBox check1;
      private static JCheckBox check2;
      private static JCheckBox check3;
      private static JCheckBox check4;
      private static JCheckBox check5;
      private static JCheckBox check6;
      private static JCheckBox check7;
      private static JCheckBox check8;
      private static JCheckBox check9;
      private static JCheckBox check10;
  
      public static void main( String[] args ){
          JFrame frame = new JFrame( "Window");
          frame.setSize( 600, 600 );
          frame.setVisible( true );
          frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  
          JButton open = new JButton("OPEN"); 
          open.setLocation( 330, 340 );
          open.setSize( 85, 30 );
          frame.add( open ); 
  
          JButton save = new JButton("SAVE"); 
          save.setLocation( 480, 340 );
          save.setSize( 85, 30 );
          frame.add( save); 
  
          check1 = new JCheckBox("option1");
          check1.setLocation( 25, 60 );
          check1.setSize( 146, 30 );
          frame.add( check1 );
  
  
          check2 = new JCheckBox("option2"); 
          check2.setLocation( 25, 90 );
          check2.setSize( 146, 30 );
          frame.add( check2 );
  
          check3 = new JCheckBox("option3");
          check3.setLocation( 25, 120 );
          check3.setSize( 146, 30 );
          frame.add( check3 );
  
          check4 = new JCheckBox("option4");
          check4.setLocation( 25, 150 );
          check4.setSize( 146, 30 );
          frame.add( check4 );        
  
          check5 = new JCheckBox("option5");
          check5.setLocation( 25, 180 );
          check5.setSize( 146, 30 );
          frame.add( check5 );
  
          check6 = new JCheckBox("option6");
          check6.setLocation( 25, 210);
          check6.setSize( 146, 30 );
          frame.add( check6 );        
  
          check7 = new JCheckBox("option7");
          check7.setLocation( 25, 240 );
          check7.setSize( 146, 30 );
          frame.add( check7 );
  
          check8 = new JCheckBox("option8");
          check8.setLocation( 25, 270 );
          check8.setSize( 146, 30 );
          frame.add( check8 );
  
          check9 = new JCheckBox("option9");
          check9.setLocation( 25, 300 );
          check9.setSize( 146, 30 );
          frame.add( check9 );
  
          check10 = new JCheckBox("option10");
          check10.setLocation( 25, 330);
          check10.setSize( 146, 30 );
          frame.add( check10 );
  
          TextArea area = new TextArea();
          area.setLocation( 320, 150 );
          area.setSize(250, 180);
          frame.add( area );
  
          frame.addKeyListener(new KeyListener() {
  
              @Override
              public void keyTyped(KeyEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void keyReleased(KeyEvent arg0) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void keyPressed(KeyEvent arg0) {
                  int keyCode = arg0.getKeyCode();
  
                  switch (keyCode) {
                  case KeyEvent.VK_1:
                      check1.setSelected(true);
                      break;
                  case KeyEvent.VK_2:
                      check2.setSelected(true);
                      break;
                  case KeyEvent.VK_3:
                      check3.setSelected(true);
                      break;
                  case KeyEvent.VK_4:
                      check4.setSelected(true);
                      break;
                  case KeyEvent.VK_5:
                      check5.setSelected(true);
                      break;
                  case KeyEvent.VK_6:
                      check6.setSelected(true);
                      break;
                  case KeyEvent.VK_7:
                      check7.setSelected(true);
                      break;
                  case KeyEvent.VK_8:
                      check8.setSelected(true);
                      break;
                  case KeyEvent.VK_9:
                      check9.setSelected(true);
                      break;
                  case KeyEvent.VK_0:
                      check10.setSelected(true);
                      break;
                  }               
              }
          });
      }
  }
  </code></pre>