Java; Getting insets before frame is visible
Assuming a normal JFrame, I'm trying to get the inset values before the frame is made visible. I can get these values fine once the frame is made visible (and i suppose I could create the jframe offscreen), but was wondering if there is some way to tickle Java into setting the insets before visibility. Prior to this call, all inset values are zero.
Net, I'm trying to get the exact dimensions of a frames client area -- or said better, I'm trying to create a JFrame that has very specific client area dimensions.
Thanks in advanc开发者_如何学Ce.
Will this help?
frame.pack();
System.out.println("Frame Insets : " + frame.getInsets() );
I'm trying to create a JFrame that has very specific client area dimensions.
Then you set the preferred size of the panel added to the frame:
panel.setPreferredSize( new Dimension(...) );
frame.add( panel );
frame.setResizable( false );
frame.pack();
frame.setVisible(true);
精彩评论