Resizing a JOGL impl

Just thought I’d submit a problem and a solution incase anyone else has the same problem.

When creating a CanvasPeer from a com.xith3d.render.jogl.RenderPeerImpl I supply a JPanel as the owner. When this JPanel is resized then the canvas is not resized.

It took me some time, but I stumbled upon a solution. If you set the layout of that JPanel to BorderLayout then it will resize the canvas.

It seems that Xith3D or JOGL adds an extra component to the owner-JPanel, which is not resized upon JPanel’s resize since the JPanel uses a FlowLayout by default (which doesn’t resize its children).

Any reason you supply a JPanel as the owner?

For a full-frame xith3d app, you can just pass the content pane of the JFrame (i.e. JFrame.getContentPane()), this resizes correctly AFAIK.

Perhaps you could submit this tip to the Xith FAQ - http://xith.org/tiki-view_faq.php?faqId=1 in case other people wish to use JPanels as well :slight_smile:

Will.

I use a JPanel because a 3D view of my model robot is just one of many user interfaces in the framework which also includes things like plots and simulation controls which help if they are all viewed and accessible at the same time.

I, too, need to use JPanel. I’ll appreciate it if you could provide some tip. Thanks in advance.

I’ve submitted a faq question and answer to the xith3d faq, but it hasn’t shown up yet. Its pretty strait forward to use with JPanel. The only other thing I have to add to what I’ve written at the top of this thread, is to use setPreferredSize() to set the panel size.

Is there anything specific your having a problem with when using JPanel?

the Q/A is approved now, if you tell me your username I can make you an “editor” so stuff shows up instantly.

Will.