Handling Mouse Motion
import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JFrame; import javax.swing.JTextField; public class Main { public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addMouseMotionListener(new MyMouseMotionListener()); JFrame f = new JFrame(); f.add(component); f.setSize(300, 300); f.setVisible(true); } } class MyMouseMotionListener extends MouseMotionAdapter { public void mouseMoved(MouseEvent evt) { System.out.println("moved:" + evt.getPoint()); } public void mouseDragged(MouseEvent evt) { System.out.println("dragged:" + evt.getPoint()); } }