Results 1 to 2 of 2
  1. #1 is offline Member
    Join Date
    Jan 2011
    Rep Power

    Default how to move this image

    I am trying to make move this image. Image is paddle.
    I have to paddle move there, where is mouse. But only along X position.

    import javax.swing.JPanel;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.*;
    import java.awt.event.*;

    public class Paddle implements MouseMotionListener

    Image paddle
    Point position;

    public Paddle()
    try{ this.paddle="paddle.jpg"));
    }catch( e){
    throw new Error("Error " + e.getMessage());

    this.position= new Point(1,575);


    public Image getImage()
    return this.paddle;

    public void setPosition(Point new)
    Point start = new Point(this.position);

    this.position.x = new.x;
    this.positio.y = new.y;


    public Point getPosition()
    return this.position;

    public void move()
    { // I don't know what to type here


    public void mouseMoved(MouseEvent e)

    { e.getPoint(); // and here.


    public void mouseDragged(MouseEvent e){};


  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    And what is the problem...does it compile? Are there exceptions? Is the behavior not what you expect? See How to ask questions and for future reference, please wrap your code using the code tags (makes it much more readable)

Similar Threads

  1. move object
    By in forum New To Java
    Replies: 3
    Last Post: 01-06-2011, 07:28 PM
  2. Help with Move Shape
    By romina in forum AWT / Swing
    Replies: 2
    Last Post: 12-09-2010, 04:25 AM
  3. To make image move
    By mneskovic in forum New To Java
    Replies: 4
    Last Post: 05-08-2010, 08:23 PM
  4. How do you move a picture?
    By Addez in forum New To Java
    Replies: 6
    Last Post: 11-03-2009, 09:44 PM
  5. Replies: 5
    Last Post: 11-02-2008, 07:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts