开发者

Usable frame size and Windows Manager frame size

开发者 https://www.devze.com 2022-12-16 11:58 出处:网络
I\'m setting a JFrame size with myFrame.setSize(Xsize,Ysize), but it gives me a probl开发者_开发百科em : this doesn\'t define the usable space in the frame but the whole frame\'s size (it include the

I'm setting a JFrame size with myFrame.setSize(Xsize,Ysize), but it gives me a probl开发者_开发百科em : this doesn't define the usable space in the frame but the whole frame's size (it include the Windows Manager frame size, which isn't always the same). Is there any way to define the JFrame size by defining the usable space size ?


Usually the best method is to setPreferredSize() on the contents of the frame and then call pack().

If that is not possible then I think calling getInsets() on the Window will grab the size of the window manager frame as long as the frame is completely visible (you may need to use a listener and wait until a windowOpened() event). I haven't actually tried this on X but it definitely works on Windows. The downside of that approach is that the frame appears and then resizes. You could start it off screen and then move it to a visible location once you have the insets.

0

精彩评论

暂无评论...
验证码 换一张
取 消