This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
在
pack()之前调用
setResizable(false)
。 “额外的空间似乎是JFrame
装饰的确切宽度和高度”并非巧合。附录:这里有一个 sscce 显示我最初的猜测是不正确的。
Invoke
setResizable(false)
beforepack()
. It's no coincidence that "extra space seems to be the exact width and height of theJFrame
's decoration."Addendum: Here's an sscce showing that my initial guess was incorrect.
结果我是从 JFrame 而不是 JPanel 进行绘制(主动渲染)...所以额外的空间是 JPanel 的 draw() 对象在 0,0 处对齐(在 JFrame 中)的结果。
由这篇文章解决。
Turns out I was drawing (active rendering) from the JFrame and not the JPanel... so the extra space was the result of the JPanel's draw() object being aligned at 0,0 (in the JFrame).
Solved by this post.