From 6befcf9f2988e8e5f4955e02f52fb5a693c692a9 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sun, 6 May 2007 01:24:55 +0000 Subject: More changes to make the GLCanvas work more reliably in the NetBeans GUI builder git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1235 232f8b59-042b-4e1e-8c03-345bb8c30851 --- src/classes/javax/media/opengl/GLCanvas.java | 68 +++++++++++++++++----------- 1 file changed, 41 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/classes/javax/media/opengl/GLCanvas.java b/src/classes/javax/media/opengl/GLCanvas.java index 4c39f912e..0f19b4aa2 100644 --- a/src/classes/javax/media/opengl/GLCanvas.java +++ b/src/classes/javax/media/opengl/GLCanvas.java @@ -118,9 +118,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { GLDrawableFactory.getFactory().chooseGraphicsConfiguration(capabilities, chooser, new AWTGraphicsDevice(device)))); - drawable = GLDrawableFactory.getFactory().getGLDrawable(this, capabilities, chooser); - context = (GLContextImpl) drawable.createContext(shareWith); - context.setSynchronized(true); + if (!Beans.isDesignTime()) { + drawable = GLDrawableFactory.getFactory().getGLDrawable(this, capabilities, chooser); + context = (GLContextImpl) drawable.createContext(shareWith); + context.setSynchronized(true); + } } public GLContext createContext(GLContext shareWith) { @@ -176,8 +178,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
addNotify in class java.awt.Component
*/ public void addNotify() { super.addNotify(); - disableBackgroundErase(); - drawable.setRealized(true); + if (!Beans.isDesignTime()) { + disableBackgroundErase(); + drawable.setRealized(true); + } if (DEBUG) { System.err.println("GLCanvas.addNotify()"); } @@ -191,29 +195,33 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { Overrides:
removeNotify in class java.awt.Component
*/ public void removeNotify() { - try { - if (Threading.isSingleThreaded() && - !Threading.isOpenGLThread()) { - // Workaround for termination issues with applets -- - // sun.applet.AppletPanel should probably be performing the - // remove() call on the EDT rather than on its own thread - if (Threading.isAWTMode() && - Thread.holdsLock(getTreeLock())) { - // The user really should not be invoking remove() from this - // thread -- but since he/she is, we can not go over to the - // EDT at this point. Try to destroy the context from here. - destroyAction.run(); + if (Beans.isDesignTime()) { + super.removeNotify(); + } else { + try { + if (Threading.isSingleThreaded() && + !Threading.isOpenGLThread()) { + // Workaround for termination issues with applets -- + // sun.applet.AppletPanel should probably be performing the + // remove() call on the EDT rather than on its own thread + if (Threading.isAWTMode() && + Thread.holdsLock(getTreeLock())) { + // The user really should not be invoking remove() from this + // thread -- but since he/she is, we can not go over to the + // EDT at this point. Try to destroy the context from here. + destroyAction.run(); + } else { + Threading.invokeOnOpenGLThread(destroyAction); + } } else { - Threading.invokeOnOpenGLThread(destroyAction); + destroyAction.run(); + } + } finally { + drawable.setRealized(false); + super.removeNotify(); + if (DEBUG) { + System.err.println("GLCanvas.removeNotify()"); } - } else { - destroyAction.run(); - } - } finally { - drawable.setRealized(false); - super.removeNotify(); - if (DEBUG) { - System.err.println("GLCanvas.removeNotify()"); } } } @@ -251,11 +259,17 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } public GL getGL() { + if (Beans.isDesignTime()) { + return null; + } + return getContext().getGL(); } public void setGL(GL gl) { - getContext().setGL(gl); + if (!Beans.isDesignTime()) { + getContext().setGL(gl); + } } public void setAutoSwapBufferMode(boolean onOrOff) { -- cgit v1.2.3