开发者

How do you find out the REAL size of a JFrame?

开发者 https://www.devze.com 2023-04-12 04:24 出处:网络
I have a 开发者_运维技巧JFrame which is maximized (frame.setExtendedState(JFrame.MAXIMIZED_BOTH)).

I have a 开发者_运维技巧JFrame which is maximized (frame.setExtendedState(JFrame.MAXIMIZED_BOTH)).

I want to find out the size it is now extended to, but frame.getSize() returns a size of (0, 0).


The frame won't have the maximized size until you make it visible. So your basic code would be:

frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
System.out.println(frame.getSize());


Using setExtendedState I got output in jframe java.awt.Dimension[width=408,height=334]. Please check your code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号