开发者

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);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜