JFrame:获取实际内容大小 [英] JFrame : Getting actual content size

查看:134
本文介绍了JFrame:获取实际内容大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个JFrame,并且试图获得它的大小与我期望的结果相比给出了不正确的结果。

I have created a JFrame, and attempting to get it's size is giving an incorrect result, compared to what I expect.

我已经确定它包含了操作系统边缘和标题栏。

I have determined that it is including the operating system borders around the edges, and the title bar.

如何获取/设置我可用于渲染的实际大小?

How can I get/set the real size which I have available for rendering?

推荐答案

您获得的大小是内容的大小 insets 。如果您使用 Jcomponent.getInsets() ,您可以通过简单的减法找到内容的大小。

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.

这篇关于JFrame:获取实际内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆