title: How to set mouseClicked event?
body: <p>I'm trying to write a program that shows me the x- and y-coordinates when I click my left mouse button, but it doesn't work. The console shows me the x- and y-coordinates automatically if I run the program, but I want to see the coordination after a mouse click.</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.SwingUtilities;
  
  public class Simple {
      public static void main(String[] args){
          Mouse maus = new Mouse();
          maus.mouseClicked(null);
      }
  }
  </code></pre>
  
  <p>Second file</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  
  public class Mouse implements MouseListener {
       public void mouseClicked(MouseEvent e) { 
           double mouseX = MouseInfo.getPointerInfo().getLocation().getX();
           double mouseY = MouseInfo.getPointerInfo().getLocation().getY();
           System.out.println(mouseX+"   "+mouseY);
      }
      @Override
      public void mouseEntered(MouseEvent arg0) {}
  
      @Override
      public void mouseExited(MouseEvent arg0) {}
  
      @Override
      public void mousePressed(MouseEvent arg0) {}
  
      @Override
      public void mouseReleased(MouseEvent arg0) {}   
  }
  </code></pre>