Is there a way to only get the title bar height in JavaFX?

Devxln :

I am trying to get only the title bar height, but so far I couldn't find an attribute in window which provides this. I want to retrieve this height because when I set the window size, it expects a value including the size of the title bar.

window.getHeight() returns the height of the window including the title bar's height, but I don't know how to retrieve the title bar height from this.

Is there maybe another way of getting the title bar's height?

MarsAtomic :

You should be able to get the height of the title bar using

titleHeight = window.getHeight() - scene.getHeight();

window.getHeight() gives you the full height of the windows, comprised of title bar and content, and scene.getHeight() is just the content. You may have to adjust for any borders you set, according to the doc.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=17915&siteId=1