views:

1166

answers:

1

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.

+4  A: 

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.

Tom Hawtin - tackline