Checking for a mouseclick on a Swing shapes

This following example create an arbitrary shape using GeneralPath and allows you to click anywhere on the JFrame. If the mouseclick x and y coordinate are within the shape, e method contains will return true.

Main.java:

import java.awt.image.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.*;
 
public class Main extends JFrame {
   private GeneralPath gp;
  
   public Main() {
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(1);
         }
      });
 
      constructShape();
  
      addMouseListener(new MouseAdapter() {
         public void mouseClicked(MouseEvent me) {
            me.translatePoint(-150, -150);
 
            if (gp.contains(me.getX(), me.getY())) {
               System.out.println(me.getX() + ", " + me.getY() + 
                                  " lies within the shape.");
            }
            else {
               System.out.println(me.getX() + ", " + me.getY() + 
                                  " lies not within the shape.");
            }
         }
      });
   }
 
   public void constructShape() {
      gp = new GeneralPath();
      gp.moveTo(   0,  100);
      gp.quadTo( -75,   25,    0, -100);
      gp.quadTo(  75,   25,    0,  100);
      gp.lineTo( -50,  -50);
      gp.lineTo(  50,  -50);
      gp.closePath();
   }   
 
   public void paint(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;
 
      // set origin to middle of window
      g2d.translate(150f, 150f);
 
      g2d.draw(gp);
   }
 
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(300, 300);
      main.setVisible(true);
   }
}