setting the inner size of a frame/window

hello, i have a jogl-rendered game in aGLCanvas which is attached to a normal Frame.

when i do
Frame.setSize(width, height);
then the window’s outer bounds are set to this size, but i actually want to set the inner size. that is the size of the gl-canvas.

unfortunately the thickness of the window-border as well as the height of titlebar is different per user and operating system, so i cant rely on standard values.

is there a way to set the inner size of a window, so that i always have the correct height and width of my GLcanvas?

thanks!

Hi,
It requires to show the frame first, but after that, you can ask for the insets for
the frame that give you the borders in pixels.

frame.setVisible(true);
Insets ins = frame.getInsets();
frame.setSize(width+ins.left+ins.right,height+ins.top+ins.bottom);

Rafael.-

thank you!

I think if you override the awt.Component.getMinimumSize() or awt.Component.getPreferredSize(), on your GLCanvas, you can call the pack() method on your frame. It will usually try to respect the minimum size of the components within.