Howdy.

http://silo.cs.indiana.edu:8346/c212/fall2015/third/08.phps

Then:

import javax.swing.*; // JFrame
import java.awt.event.*; // MouseMotionListener MouseEvent

public class One extends JFrame implements MouseMotionListener {
  public void mouseMoved(MouseEvent e) { 
    System.out.println("Mouse being moved."); 
  }
  public void mouseDragged(MouseEvent e) { 
    int x = e.getX(), y = e.getY(); 
    System.out.println("Mouse being dragged at (" + x + ", " + y + ")"); 
  }
  public One() {
    super();
    this.setVisible(true); 
    this.setSize(400, 400); 
    // https://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#addMouseMotionListener(java.awt.event.MouseMotionListener)
    this.addMouseMotionListener( this ); 
  }
  public static void main(String[] args) {
    One a = new One(); 
    
  }
}

Now: report the location of the mouse when dragged in the frame.

import javax.swing.*; // JFrame

public class One extends JFrame {
  public One() {
    super();
    this.setVisible(true); 
    this.setSize(400, 400); 
    this.add( new Screen() ); 
  }
  public static void main(String[] args) {
    One a = new One(); 
    
  }
}

import javax.swing.*; // JComponent
import java.awt.*; // Graphics 
import java.awt.event.*; // MopuseMotionListener MouseEvent

public class Screen extends JComponent implements MouseMotionListener {
  public Screen() {
    super(); 
    this.addMouseMotionListener(this); 
    this.x = 200;
    this.y = 200; 
  }
  public void mouseMoved(MouseEvent e) { } 
  public void mouseDragged(MouseEvent e) { 
    this.x = e.getX();
    this.y = e.getY(); 
    this.repaint(); 
    System.out.println( " ha ha ha (" + this.x + ", " + this.y + ")" );
  } 
  int x, y;

  public void paintComponent(Graphics g) {
    g.drawString("(" + x + ", " + y + ")", x, y);
  }
}

--