Java tutorial
import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JFrame; import javax.swing.JTextArea; public class Main extends JFrame { public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 400); JTextArea textArea = new JTextArea("drag it..."); textArea.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { System.out.println("Mouse Dragged..."); } public void mouseMoved(MouseEvent e) { System.out.println("Mouse Moved..."); } }); getContentPane().add(textArea); } public static void main(String[] args) { new Main().setVisible(true); } }