setUsingNativeTitleBar() question

I just started calling this routine in my main window class, and as a result, the window appears to be about 30 pixels taller than it was before. This is happening on both Mac and Windows.

The title bars look great, but I’m wondering why there’s this unexpected side effect. Any ideas?

Well if you add a 30-pixel high title bar, your window will be 30 pixels higher. Is it really such an unexpected side-effect!? You could always make your window 30 pixels shorter. Or am I missing your point here?

I must be making a bad assumption about setUsingNativeTitleBar(). I thought it would change the look of the title bar based on platform, not the height of the title bar, or the height of the window.

Without that call, I get a title bar from the default LookAndFeel class, the window height looks correct at 700 pixels.

With the call, I get a native title bar that looks to be the same height, but now my window looks correct when set to 670 pixels.

I was assuming that setUsingNativeTitleBar() would simply switch the look of the title bar I got on various platforms leaving the window height constant, but from what you’re saying, it adds 30 pixels to the window height as well.

You can see the same result by adding the setUsingNativeTitleBar() call to the “hello world” demo.

No, it doesn’t ‘add’ per say, but rather it puts your window inside a natively drawn window. That extra window may be 30 px higher, it may be 60, it may be 90, it may be 12, who knows. On my system it is 36 due to the theme I am using. The native titlebar uses the real native titlebar of the system, something you will have no control over. So no, it does not just ‘change the look’ (which would be horrendously unreliable anyway considering how different themes are around), it gives it a real titlebar.

Ah. Now I understand. Thanks!

Is there a way to get the height of this new window that my component
is in, so I can adjust the height reliably? I’m experiencing the expected:
that if I set the window height to be correct on my system, it will be off on
another user’s machine.

yes - ComponentPeer::getFrameSize()

perfect. Thanks!