Please HELP "Unable to lock surface"

Hi I have to following code that does not work :’(
I’m creating dummy listenner for the canvas
because I will never need a display

The error that I’m gettin is
net.java.games.jogl.GLException: Unable to lock surface

  at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.lockSurface(WindowsOnscreenGLContext.java:155)

  at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.makeCurrent(WindowsOnscreenGLContext.java:107)

  at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:162)

  at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:182)

  at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)

  at silver.ui.Panel3D.<init>(Panel3D.java:82)

class DummyListener implements GLEventListener{

private GL gl;
public void init(GLDrawable drawable) {
        
  gl = drawable.getGL();
}

public void display(GLDrawable drawable) {
        gl = drawable.getGL();

}
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {}
public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {}

}

public class Panel3D extends javax.swing.JPanel implements GLEventListener, java.util.Observer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener {
/** Creates new form Panel3D */
public Panel3D(View view) {



Frame frame = new Frame(“Silver”);
canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
canvas.addGLEventListener(new DummyListener());
canvas.setNoAutoRedrawMode(true);
canvas.setSize(m_viewData.getWidth(), m_viewData.getHeight());
canvas.requestFocus();
frame.add(canvas);
if (!canvas.canCreateOffscreenDrawable()) {
throw new GLException(“Parent window doesn’t support creation of pbuffers”);
}
GLCapabilities caps = new GLCapabilities();
caps.setDoubleBuffered(false);
pbuffer = canvas.createOffscreenDrawable(caps,m_viewData.getWidth(), m_viewData.getHeight());
pbuffer.addGLEventListener(this);
canvas.display();

Thanks a lot
Ross

Try making your frame visible before calling canvas.display().

Hi

Thanks a lot fot the respond
It did work for me

I have another question
If instead of the frame I have JInternalFrame
can I somehow add a cnavas to it
I can not figure it out

Thanks a lot

Ross

It is just like a jframe, you call getContentPane().add.