GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
GLCanvas canvas = new GLCanvas();
  public void run(String[] args) {    GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());    canvas.addGLEventListener(new Listener());    canvas.setSize(256, 256);    frame1 = new Frame("Frame 1");    frame1.setLayout(new BorderLayout());    frame1.add(canvas, BorderLayout.CENTER);    emptyCanvas = new Canvas();    emptyCanvas.setBackground(Color.GRAY);    emptyCanvas.setSize(256, 256);    frame2 = new Frame("Frame 2");    frame2.setLayout(new BorderLayout());    frame2.add(emptyCanvas, BorderLayout.CENTER);    frame1ContainedComponent = canvas;    frame2ContainedComponent = emptyCanvas;    frame1.pack();    frame1.show();    frame2.pack();    frame2.show();    frame2.setLocation(256 + BORDER_WIDTH, 0);        JFrame uiFrame = new JFrame("Controls");    uiFrame.getContentPane().setLayout(new GridLayout(3, 1));    JButton button = new JButton("Toggle Frame 1's component");    button.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {          if (frame1ContainedComponent == null) {            frame1ContainedComponent = frame1RemovedComponent;            frame1RemovedComponent = null;            frame1.add(frame1ContainedComponent);          } else {            frame1RemovedComponent = frame1ContainedComponent;            frame1ContainedComponent = null;            frame1.remove(frame1RemovedComponent);          }        }      });    uiFrame.getContentPane().add(button);    button = new JButton("Swap Frame 1's and Frame 2's components");    button.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {          System.out.println("Swapping Frame 1's and Frame 2's components");          Component t1 = null, t2 = null;          t1 = frame1ContainedComponent;          t2 = frame2ContainedComponent;          if (t1 != null) {            frame1.remove(t1);          }          if (t2 != null) {            frame2.remove(t2);          }          if (t1 != null) {            frame2.add(t1);          }          if (t2 != null) {            frame1.add(t2);          }          frame1ContainedComponent = t2;          frame2ContainedComponent = t1;          t1 = frame1RemovedComponent;          frame1RemovedComponent = frame2RemovedComponent;          frame2RemovedComponent = t1;        }      });    uiFrame.getContentPane().add(button);    button = new JButton("Toggle Frame 2's component");    button.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {          if (frame2ContainedComponent == null) {            frame2ContainedComponent = frame2RemovedComponent;            frame2RemovedComponent = null;            frame2.add(frame2ContainedComponent);          } else {            frame2RemovedComponent = frame2ContainedComponent;            frame2ContainedComponent = null;            frame2.remove(frame2RemovedComponent);          }        }      });    uiFrame.getContentPane().add(button);    uiFrame.pack();    uiFrame.show();    uiFrame.setLocation(512 + BORDER_WIDTH + BORDER_WIDTH, 0);    final Animator animator = new Animator(canvas);    WindowListener windowListener = new WindowAdapter() {        public void windowClosing(WindowEvent e) {          // Run this on another thread than the AWT event queue to          // make sure the call to Animator.stop() completes before          // exiting          new Thread(new Runnable() {              public void run() {                animator.stop();                System.exit(0);              }            }).start();        }      };    frame1.addWindowListener(windowListener);    frame2.addWindowListener(windowListener);    uiFrame.addWindowListener(windowListener);    animator.start();  }