System.exit(0);
try { while (!quit) { if (viewer != null) { try { if (drawing) { canvas.getSize(dim); water.addDroplet(new Water.Droplet( 2 * (mousePosX / (float) dim.width  - 0.5f), -2 * (mousePosY / (float) dim.height - 0.5f), 0.08f)); } water.tick(); canvas.display(); } catch (GLException e) {    e.printStackTrace(); } } else {  canvas.display(); } } } finally { System.exit(0); }
  public void run(String[] args) {    canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());    canvas.addGLEventListener(new Listener());    canvas.setNoAutoRedrawMode(true);    Frame frame = new Frame("Procedural Texture Waves");    frame.setLayout(new BorderLayout());    canvas.setSize(512, 512);    frame.add(canvas, BorderLayout.CENTER);    frame.pack();    frame.show();    canvas.requestFocus();    frame.addWindowListener(new WindowAdapter() {        public void windowClosing(WindowEvent e) {          quit = true;        }      });    water = new Water();    water.initialize("demos/data/images/nvfixed.tga",                      "demos/data/images/nvspin.tga",                      "demos/data/images/droplet.tga",                      "demos/data/cubemaps/CloudyHills_{0}.tga",                     canvas);    while (!quit) {      if (viewer != null) {        try {          if (drawing) {            canvas.getSize(dim);            water.addDroplet(new Water.Droplet( 2 * (mousePosX / (float) dim.width  - 0.5f),                                                -2 * (mousePosY / (float) dim.height - 0.5f),                                                0.08f));          }          water.tick();          canvas.display();        } catch (GLException e) {          // Have seen spurious exceptions getting thrown during SwapBuffers.          // Not sure why at this time; disabling of repaint() should prevent          // AWT thread from getting involved. Continue animating anyway.          e.printStackTrace();        }      } else {        // Make the pbuffer get created        canvas.display();      }    }    System.exit(0);  }