title: Moving images in Java
body: <p>I want to make an image that I drew in the paint class move left across my <code>JFrame</code> as a timer ticks. But  I don't know how to do that. Also, I am trying to get my program to make the image disappear when the image is clicked upon.</p>
  
  <h3>movingball class</h3>
  
  <pre><code>import java.awt.Graphics2D;    
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.geom.Ellipse2D;
  import javax.swing.JPanel;
  import javax.swing.Timer;
  
  public class movingball extends JPanel{
  
      private int move=50;
      private Timer timer = new Timer(move, new TimerListener());
      private int radius = 10;
      private int x = 300;    
      private int y = 0;
  
      public  movingball() {
            timer.start();
      }
  
      private class TimerListener implements ActionListener{
      public void actionPerformed(ActionEvent e){
          x=x-20;
          repaint();  }//trying to get the oval to move left 20 
      }
  
      protected void paintComponent(Graphics2D g){
      super.paintComponent(g);
      g.fillOval(x, 100 , radius * 2, radius * 2);    }
      }
  </code></pre>
  
  <h3>movingControl class</h3>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.event.InputEvent;
  import java.awt.event.ItemEvent;
  import java.awt.event.MouseAdapter;
  import java.awt.event.MouseEvent;    
  import javax.swing.JPanel;
  
  public class movingControl extends JPanel {
  
  private movingball ball= new movingball();
  
  public movingControl(){
      JPanel panel = new JPanel();
      ball.setBorder(new javax.swing.border.LineBorder(Color.red));
      panel.addMouseListener(new movingballListener());
      setLayout(new BorderLayout());
      add(ball, BorderLayout.CENTER);
      add(panel, BorderLayout.SOUTH);
  }
  }
  </code></pre>
  
  <h3>SnniperGameApp class</h3>
  
  <p>I know I spelled sniper wrong</p>
  
  <pre><code>import javax.swing.JApplet;
  
  public class SnniperGameApp extends JApplet {
  
  static final long serialVersionUID = 2777718668465204446L;
  //i dont know what this serial thing is. But my program wont start without it
  
  public SnniperGameApp(){
      add(new movingControl());
  }
  }
  </code></pre>
  
  <h3>ClickingEvent class</h3>
  
  <pre><code>import java.awt.event.InputEvent;
  import java.awt.event.ItemEvent;
  import java.awt.event.MouseAdapter;
  import java.awt.event.MouseEvent;
  
  class movingballListener extends MouseAdapter{
  
      public void mouseReleased(MouseEvent e) {
          if ((e.getModifiers() &amp; InputEvent.BUTTON1_DOWN_MASK) != 0) {
            System.out.println(  (e.getPoint()));}}
      }
  </code></pre>