How Do You Get the Height of the Titlebar Using Java (Swing)?

By : jjnguy
Source: Stackoverflow.com
Question!

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.

By : jjnguy


Answers

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.



Stanford has some excellent computer science classes online

http://see.stanford.edu/SEE/Courses.aspx

By : RichH


If you're looking for a broader, in-depth approach, take a look at MIT's OpenCourseware.

"MIT OpenCourseWare (OCW) is a web-based publication of virtually all MIT course content. OCW is open and available to the world and is a permanent MIT activity."

http://ocw.mit.edu/OcwWeb/web/courses/courses/index.htm#ElectricalEngineeringandComputerScience

Pertinent to your question, the "Introduction to Computer Science and Programming" course uses Python. There are also dozens of other courses offered, and many more at different institutions around the continent.



This video can help you solving your question :)
By: admin