I am getting a MouseEvent
in Java. the getPoint()
method is adding the height of the title bar into the y portion of the coordinate.
I was wondering how I can find the height of the title bar of the current window in order to offset the y value by the correct amount.
You can find the frame insets by calling the getInsets method (defined in Container). Frame insets are discussed at the top of the Frame API docs. See this question.
Of course you could always add your mouse listener to the content pane. JFrame has some unexpected behaviour on some methods such as add
and setLayout
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With