MouseMotionListener

Ok in my simple pong game, I want the paddle to follow the postion of the mouse. So I have “implements MouseMotionListener” with the two methods mouseDragged and mouseMoved. In mouseMoved I have…


	public void mouseMoved(MouseEvent m){
		vBarY = m.getY();
		hBarX = m.getX();
	}

But the bars aren’t moving. Is there something I’m missing?

Did you register the listener to the component?

component.addMouseMotionListener(myListener);

Do you repaint often enough to make the changes appearant when you expect them?

Aha! Thatwas the problem. Forgot to addmousemotionlistener() Thankyou!