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

后端 未结 6 2086
名媛妹妹
名媛妹妹 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:16

    The top border of frame is of size 30.You can write code for printing the coordinate of any point on the frame using MouseInputAdapter.You will find when the cursor is just below the top border of the frame the y coordinate is not zero , its close to 30.Hence if you give size to frame 300 * 300 , the size available for putting the components on the frame is only 300 * 270.So if you need to have size 300 * 300 ,give 300 * 330 size of the frame.

提交回复
热议问题