----------------------------------- Jonny Tight Lips Fri Sep 09, 2005 3:42 pm Mouse location ----------------------------------- I was wondering what / if there is a command to find the location of the mouse. In turing it is mousexy() or something like that. Of course being Java it has to be harder then that. I've been looking at some examples online but non of them make sence to me. So any help you can give would be nice. Thx ----------------------------------- wtd Fri Sep 09, 2005 3:51 pm ----------------------------------- Have your class implement MouseMotionListener. http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/MouseMotionListener.html ----------------------------------- Jonny Tight Lips Fri Sep 09, 2005 6:16 pm ----------------------------------- Well it compiles now but nothing happens. Now remember I'm new at this so there are probably a lot of mistakes so feel free to poit them out. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class pong extends JComponent implements MouseMotionListener { Image ball = new ImageIcon("ball.gif").getImage(); Image paddle = new ImageIcon("paddle.gif").getImage(); int x = 100; int y = 100; int px = 10; int py = 10; int dx = 2; int dy = 2; public void begin(){ while (true){ run2(); } } public void mouseMoved(MouseEvent e){ px = e.getX(); py = e.getY(); } public void mouseDragged(MouseEvent e){ } public void paint(Graphics g) { g.drawImage(ball, x, y, this); g.drawImage(paddle,px,py,this); } public void run2() { try { x = x+dx ; y = y+dy; if (x+19 > 800){ dx = dx*-1; } if (y+19 > 500){ dy = dy*-1; } if (x