title: Why is my oval not moving Java
body: <p>i was writing a little snake like game and i was implementing the key event listener, so it listens when the arrow keys are pressed it increment or decrement the position of the oval in the frame. Below is my code, what do you think is happening? i tried googling for possible solution, but i turned out empty.</p>
  
  <pre><code>package snakegame;
  
  import java.awt.Graphics;
  import java.awt.event.KeyAdapter;
  import java.awt.event.KeyEvent;
  import javax.swing.JFrame;
  
  /**
   *
   * @author PlaixHax0r
   */
  public class SnakeGame extends JFrame{
  
      int x, y;
  
      public class ActionListener extends KeyAdapter{
          public void KeyPressed(KeyEvent a){
  
              int KeyCode = a.getKeyCode();
  
              if(KeyCode == KeyEvent.VK_RIGHT){
                  x++;
              }
  
              if(KeyCode == KeyEvent.VK_LEFT){
                  x--;
              }
  
              if(KeyCode == KeyEvent.VK_DOWN){
                  y++;
              }
  
              if(KeyCode == KeyEvent.VK_UP){
                  y--;
              }
  
  
          }
  
          public void KeyReleased(KeyEvent a){
  
          }
  
      }
  
  
  
      public SnakeGame(){
          addKeyListener(new ActionListener());
          setTitle("Snake 1.0");
          setVisible(true);
          setSize(500, 500);
          setResizable(false);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
  
          x=150;
          y=150;
  
      }
  
      public void paint(Graphics g){
          g.drawString("Welcome to Snake Empire", 180, 50);
          g.fillOval(x, y, 15, 15);
  
          repaint();
      }
  
  
      public static void main(String[] args) {
          new SnakeGame();
  
      }
  }
  </code></pre>