JFrame : Getting actual content size

北城余情 提交于 2019-12-01 03:54:52

The size you are getting is the size of the content and the size of the insets. If you use Jcomponent.getInsets(), you can find the size of the content with simple subtraction.

Your question is confusing: JPanels don't have title bars or window borders, they are abstract containers that are INSIDE JFrames. JFrames are the objects with title bars and window borders.

JPanel.getSize() should work as intended. However, for JFrames you'll want to use JFrame.getContentPane().getSize(), because getContentPane() returns the JPanel (which is the actual content area).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!