I have a glcanvas inside a jpanel with a BorderLayout. The size of the canvas should be dependent on the window size. The initial size is set via
glCanvas.setSize(640, 480);
And it is added to the panel like this
jPanel3DModel.add(Model3DCanvas.getInstance().getCanvas());
jPanelRight.add(jPanel3DModel, BorderLayout.NORTH);
However the size of the canvas is fixed and all the panels of the other components in my frame just resize.
If you have to react to the
JPanelresize "manually", you can use aComponentListeneras described in https://docs.oracle.com/javase/tutorial/uiswing/events/componentlistener.htmlAssuming
canvasis your GLCanvas andjpanelthe component your canvas resizing is depending on.