Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java; Getting insets before frame is visible

Tags:

java

swing

jframe

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.

like image 810
RobNY Avatar asked Sep 17 '10 02:09

RobNY


1 Answers

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);
like image 142
camickr Avatar answered Nov 09 '22 15:11

camickr