Resize CanvasPeer in JFrame

I am working on a project and added a CanvasPeer to a JPanel in a JFrame. What I need to do now is figure out a way to resize the CanvasPeer when the JFrame is resized.

I added a ComponentListener to my JPanel and in the componentResized method I did the following:

canvasPeer.resize(newWidth, newHeight)

But this doesn’t seem to work. Is there another way?

Thanks.

Gregg

Hi,

I use a JPanel as CanvasPeer as well and it resizes automatically when the JFrame parent is resized. What Layout are you using ? I use BorderLayout.

thats what I use: (I get the input panel from a frame)
javax.swing.JPanel panel
= panel;
CanvasPeer cp = rp.makeCanvas(panel
,panel_.getWidth(),panel_.getHeight(),32,false);
canvas = new Canvas3D();
canvas.set3DPeer(cp);

Ca$