How do you find out the REAL size of a JFrame?
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.
精彩评论