Source
<span style= "FONT-SIZE:14PX;" >import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import Java.awt.event.WindowListener; Import java.awt.event.MouseMotionAdapter; import Java.awt.event.MouseMotionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseAdapter; import java.awt.event.KeyAdapter; import Java.awt.event.KeyListener; import java.awt.event.MouseListener; import Javax.swing.JTextArea; import javax.swing.JFrame; import javax.swing.JScrollPane; import Javax.swing.JPasswordField; class Mymouse extends jframe{ JTextArea Text = new JTextArea (); Public Mymouse () {super.settitle ("mouse sprite"); Super.addmousemotionlistener (New Mousemotionadapter () {public void mousedragged (MouseEvent e) {System.out.println ("x-coordinate:" +e.getx () + "y-coordinate:" +e.gety ()) ; } }) ; Super.addwindowlistener (New Windowadapter () {public void windowclosing (WindowEvent e) { System.exit (1); } }) ; Super.setsize (400,300); Super.setvisible (TRUE); }}; class tester{public static void Main (String args[]) {mymouse MHK = new Mymouse (); }};</span>
Java implementation Mouse Drag-and-drop action monitoring