Why does the JFrame setSize() method not set the size correctly?

后端 未结 6 2094
名媛妹妹
名媛妹妹 2020-12-16 12:40

So I\'ve been programming in java for a semester or so, and I\'ve had this problem a few times and finally got around to asking.

If I make a JFrame and

6条回答
  •  孤城傲影
    2020-12-16 13:14

    On OS X, you need to take into account existing window decorations. They add 22 pixels to the height. So on a JFrame, you need to tell the program this:

    frame.setSize(width, height + 22);
    

提交回复
热议问题