tags:

views:

59

answers:

1

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 advance.

+3  A: 

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);
camickr
I wanted to do this without adding anything to the frame. In fact, I remove the frame's layout too. However, you did point me in the right direction -- seems pack() is the tickle I was looking for. Now, if I do a) create JFframe, b) setLayout(null) c) myJFrame.pack(), and THEN get the insets, it does exactly what I was hoping. Following this, I set the actual JFrame size (taking into account the insets) and I'm right where I need to be. Thanks for pointing me in the right direction.
RobNY