GLCanvas not initializing properly

I moved my application over to XP from Linux and when my swing UI initializes, the GLCanvas component didn’t seem to do anything. I have this in a tabbed pane and if I bring up another tab, then switch back to my GLCanvas tab, it initializes and I see the black screen.

Anyone have ideas here?

GLCanvas should work properly in a JTabbedPane. First, make sure you are running with -Dsun.java2d.noddraw=true. Second, you may need to restructure portions of your application to properly handle multiple calls to GLEventListener.init(). I believe the JTabbedPane implementation causes addNotify/removeNotify to be called on the GLCanvas as you switch from tab to tab, so you may need to reinitialize texture objects and display lists in your init() method which are used in your display() method.

Could you post a small and self-contained test case (or better yet, open an Issue using the JOGL Issue Tracker and add it as an attachment)? Thanks.

GLCanvas overrides addNotify and removeNotify which are the necessary events.

If you’re making modifications to the component hierarchy after it’s been realized, make sure you’re doing so on the AWT Event Queue thread. See EventQueue.isDispatchThread() and EventQueue.invokeAndWait()/invokeLater().

I believe it should show up properly in this situation. I’ve seen apps using JTabbedPane and GLCanvas which work fine on at least Mac OS X and Windows. Currently the GLCanvas’s behavior is undefined if you remove it from the component hierarchy from another thread than the AWT event queue thread. You might get an exception, or it might work, depending on your OpenGL drivers.

After setVisible(true) has been called.