简体   繁体   English

Java JDesktopPane / JInternalFrame居中问题

[英]Java JDesktopPane/JInternalFrame Centering Issue

I'm working with JDesktopPane 's and JInternalFrame 's and I'm having some difficulty centering the frames in the desktop. 我正在使用JDesktopPaneJInternalFrame ,但在将框架居中放置在桌面时遇到了一些困难。 What I've found is that when I determine the center of the desktop using getWidth() and getHeight() , the position I get is the center of the desktop if the JFrame wasn't maximized. 我发现,当我使用getWidth()getHeight()确定桌面的中心时,如果JFrame没有最大化,我得到的位置就是桌面的中心。 Is there a way to get the 'real' dimensions of the desktop? 有没有办法获得桌面的“真实”尺寸?

好的,经过几个小时的调试,我弄清楚了问题所在:直到我完成所有内容的添加/放置之后, JFrame才变得可见,因此未将其设置为最大大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM