GLDrawableFactory.getFactory().createGLJPanel(caps);
new GLJPanel(caps);
  private JInternalFrame addWindow(int which) {    // FIXME: workaround for problem in 1.6 where ALL Components,    // including Swing components, are Finalizable, requiring two full    // GC cycles (and running of finalizers) to reclaim    System.gc();    // Try to get finalizers run    try {      Thread.sleep(1);    } catch (InterruptedException e) {    }    System.gc();    String str = "";    switch (which) {    case GEARS:     str = "Gears Demo"; break;    case HDR:       str = "High Dynamic Range Rendering Demo"; break;    case HWSHADOWS: str = "ARB_shadow Shadows"; break;    case INFINITE:  str = "Infinite Shadow Volumes"; break;    case REFRACT:   str = "Refraction Using Vertex Programs"; break;    case VBO:       str = "Very Simple vertex_buffer_object demo"; break;    case WATER:     str = "Procedural Texture Waves"; break;    }    final JInternalFrame inner = new JInternalFrame(str);    inner.setResizable(true);    inner.setClosable(true);    inner.setVisible(true);    GLCapabilities caps = new GLCapabilities();    if (which == INFINITE) {      caps.setStencilBits(16);    }    final GLJPanel canvas =      (which == GEARS) ?      new JGears() :      GLDrawableFactory.getFactory().createGLJPanel(caps);    final DemoListener demoListener = new DemoListener() {        public void shutdownDemo() {          removeJPanel(canvas);          SwingUtilities.invokeLater(new Runnable() {              public void run() {                inner.doDefaultCloseAction();              }            });        }        public void repaint() {          canvas.repaint();        }      };    Demo demo = null;    switch (which) {      case GEARS: {        // GLEventListener already added        break;      }      case HDR: {        demo = new HDR();        ((HDR) demo).setup(null);        inner.setSize(((HDR) demo).getPreferredWidth(), ((HDR) demo).getPreferredHeight());        break;      }      case HWSHADOWS: {        demo = new HWShadowmapsSimple();        break;      }      case INFINITE: {        demo = new InfiniteShadowVolumes();        break;      }      case REFRACT: {        demo = new VertexProgRefract();        break;      }      case VBO: {        demo = new VertexBufferObject();        break;      }      case WARP: {        demo = new VertexProgWarp();        ((VertexProgWarp) demo).setTitleSetter(new VertexProgWarp.TitleSetter() {            public void setTitle(final String title) {              SwingUtilities.invokeLater(new Runnable() {                  public void run() {                    inner.setTitle(title);                  }                });            }          });        break;      }      case WATER: {        demo = new ProceduralTexturePhysics();        break;      }    }    if (which != GEARS) {      demo.setDemoListener(demoListener);      canvas.addGLEventListener(demo);    }    canvas.addMouseListener(new MouseAdapter() {        public void mouseClicked(MouseEvent e) {          canvas.requestFocus();        }      });    addJPanel(canvas);    final Demo fDemo = demo;    inner.addInternalFrameListener(new InternalFrameAdapter() {        public void internalFrameClosed(InternalFrameEvent e) {          if (fDemo != null) {            fDemo.shutdownDemo();          }        }      });    inner.getContentPane().setLayout(new BorderLayout());    /*    if (which == REFRACT) {      // Testing scrolling      canvas.setSize(512, 512);      canvas.setPreferredSize(new Dimension(512, 512));      JScrollPane scroller = new JScrollPane(canvas);      inner.getContentPane().add(scroller);      } else */ if (which == GEARS) {      // Provide control over transparency of gears background      canvas.setOpaque(false);      JPanel gradientPanel = JGears.createGradientPanel();      inner.getContentPane().add(gradientPanel, BorderLayout.CENTER);      gradientPanel.add(canvas, BorderLayout.CENTER);      final JCheckBox checkBox = new JCheckBox("Transparent", true);      checkBox.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent e) {            canvas.setOpaque(!checkBox.isSelected());          }        });      inner.getContentPane().add(checkBox, BorderLayout.SOUTH);    } else {      inner.getContentPane().add(canvas, BorderLayout.CENTER);    }    if (which != HDR) {      inner.setSize(512, 512);    }    desktop.add(inner);    return inner;  }