How to get the inner div coordinates from a Mouseclick

Hi,

i try to get the pixel coordinates x,y from a mouse click in a div.
I found this but it does not work anymore. I tried both variant.
Is there a way achiv this ?

  Div test2 = new Div();
        test2.addClickListener(e -> {
            //int x = e.getRelativeX();
            //int y = e.getRelativeY();
            int x = e.getClientX() - e.getOffsetX();
            int y = e.getClientY() - e.getOffsetY();
            System.out.println("x = " + x + ", y = " + y);
        });