In this code I have created a JFrame to display the x and y points of the spot the users have clicked. As you can see in the example the y point is a really high number because it is taking the title bar height into consideration. How can i get it so the top left corner that is clickable is 0,0?

Right now (0,0) is out of reach and i'm not to sure how to incorporate the JPanel in order to be able to reach that point.

I can further explain my code or clarify if needed

[![example](https://i.stack.imgur.com/sm8tr.png)](https://i.stack.imgur.com/sm8tr.png)

```
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class Proj07Runner {
    Proj07Runner() { 
        System.out.println(
          "Terminal");
       new GUI();
    }
} 

class MyFrame extends Frame {
  int clickX;
  int clickY;
  public void paint(Graphics g) {
      g.drawString(" " + clickX + ", " + clickY, clickX, clickY);
  } 
} 

class GUI { 
  public GUI(){ // constructor - set up frame
    MyFrame frame = new MyFrame();
    frame.setSize(300,100);
    frame.setTitle("xxx");
    frame.setVisible(true);

    // window listent to allow users to close frame 
    frame.addWindowListener(new Close());

    // mouse listener so we can print points for mouse clicks
    frame.addMouseListener(new MouseProc(frame));

    // JPanel
    JPanel panel = new JPanel();
    frame.add(panel);
    } 
} 

// monitors closing window
class Close extends WindowAdapter{
  public void windowClosing(WindowEvent e){
    System.exit(0);
  }
}

// Monitor mouse clicks and gather x and y points
class MouseProc extends MouseAdapter {
    MyFrame reference; 
    MouseProc(MyFrame winIn) { 
      reference = winIn;
    } 

    @Override
    public void mousePressed(MouseEvent e) {
      reference.clickX = e.getX();
      reference.clickY = e.getY();
      reference.repaint();
    }
} 

```