title: Timer not working for moving ball
body: <p>I am trying to get the timer working to move the ball. It just isn't working. I am getting alot of errors which i don't yet understand</p>
  
  <p>Can someone tell me what i am doing wrong.</p>
  
  <p>Here is the error that i got.</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  at Paneel$TimerHandler.actionPerformed(Paneel.java:30)
  at javax.swing.Timer.fireActionPerformed(Unknown Source)
  at javax.swing.Timer$DoPostEvent.run(Unknown Source)
  at java.awt.event.InvocationEvent.dispatch(Unknown Source)
  at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
  at java.awt.EventQueue.access$500(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.awt.EventQueue$3.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
  at java.awt.EventQueue.dispatchEvent(Unknown Source)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
  at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.*;
  
  public class Paneel extends JPanel 
  {
      private int height, width;
      private boolean moveLeft, moveRight, moveUp, moveDown;
      private Timer timer;
      private Ball ball;
  
      public Paneel() 
      {
          TimerHandler timerHandler = new TimerHandler();
          timer = new Timer(20, timerHandler);
          timer.start();
      }
  
      public void paintComponent(Graphics pen)
      {
          super.paintComponent(pen);
          ball = new Ball((double)getWidth(), (double)getHeight());
          ball.drawBall(pen);
      }
  
      class TimerHandler implements ActionListener
      {
          public void actionPerformed(ActionEvent e) 
          {
              ball.moveDown();
              repaint();
          }
      }
  }
  </code></pre>