private GLCanvas createGLCanvas(final GLCapabilitiesImmutable caps, final Dimension size) {
   final GLCanvas canvas = new GLCanvas(caps);
   canvas.setSize(size);
   canvas.setPreferredSize(size);
   canvas.setMinimumSize(size);
   return canvas;
 }
  @Override
  public GLAutoDrawable createGLAutoDrawable(
      final QuitAdapter quitAdapter,
      final GLCapabilitiesImmutable caps,
      final int width,
      final int height)
      throws InterruptedException, InvocationTargetException {
    final GLAutoDrawable glad;
    if (caps.isOnscreen()) {
      final Frame frame = new Frame("Gears AWT Test");
      Assert.assertNotNull(frame);

      final GLCanvas glCanvas = new GLCanvas(caps);
      Assert.assertNotNull(glCanvas);
      final Dimension glc_sz = new Dimension(width, height);
      glCanvas.setMinimumSize(glc_sz);
      glCanvas.setPreferredSize(glc_sz);
      glCanvas.setSize(glc_sz);
      glad = glCanvas;

      new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter), glCanvas).addTo(frame);

      frame.setLayout(new BorderLayout());
      frame.add(glCanvas, BorderLayout.CENTER);
      javax.swing.SwingUtilities.invokeAndWait(
          new Runnable() {
            public void run() {
              frame.pack();
              frame.setVisible(true);
            }
          });
    } else {
      final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile());
      glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height);
      Assert.assertNotNull(glad);
    }
    return glad;
  }
  public AnimationPanel(GLEventListener renderer, AnimationTrigger trigger, Dimension dim) {
    super(new MigLayout("insets 0, nogrid, center, fill", "center", "center"));

    GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2));

    _canvas = new GLCanvas(caps);
    _canvas.setName("glCanvas");
    _canvas.setMinimumSize(new Dimension(5, 5));
    setRenderer(renderer);

    if (trigger != null) {
      _defaultTrigger = null;
      _altTrigger = trigger;
      _altTrigger.setCanvas(_canvas);
    } else {
      _altTrigger = null;
      _defaultTrigger = new Animator(_canvas);
      _defaultTrigger.setPrintExceptions(true);
    }

    add(_canvas);
    setSize(dim);
  }