From 69ca977ccf8d329cd72dced5ebb92501da460561 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Mon, 14 Feb 2005 22:19:43 +0000 Subject: Fixed problem in demos introduced in 1.1 b08 where windowClosing events were not properly waiting for the Animator to stop. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@55 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4 --- src/demos/cg/runtime_ogl/cgGL_vertex_example.java | 11 +++++++++-- .../runtime_ogl_vertex_fragment.java | 18 ++++++++++++------ src/demos/gears/Gears.java | 11 +++++++++-- src/demos/jgears/JGears.java | 11 +++++++++-- src/demos/tess/Tess.java | 11 +++++++++-- .../testContextDestruction/TestContextDestruction.java | 11 +++++++++-- src/demos/vertexArrayRange/VertexArrayRange.java | 11 +++++++++-- src/demos/vertexBufferObject/VertexBufferObject.java | 11 +++++++++-- src/demos/vertexProgRefract/VertexProgRefract.java | 11 +++++++++-- src/demos/vertexProgWarp/VertexProgWarp.java | 11 +++++++++-- 10 files changed, 93 insertions(+), 24 deletions(-) (limited to 'src/demos') diff --git a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java index 16c3e1a..ec2cb9a 100644 --- a/src/demos/cg/runtime_ogl/cgGL_vertex_example.java +++ b/src/demos/cg/runtime_ogl/cgGL_vertex_example.java @@ -267,8 +267,15 @@ public class cgGL_vertex_example implements GLEventListener final Animator animator = new Animator(canvas); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); frame.show(); diff --git a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java index 38ab297..3ceabc0 100644 --- a/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java +++ b/src/demos/cg/runtime_ogl_vertex_fragment/runtime_ogl_vertex_fragment.java @@ -74,12 +74,18 @@ public class runtime_ogl_vertex_fragment implements GLEventListener frame.setSize(512, 512); final Animator animator = new Animator(canvas); frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - animator.stop(); - System.out.println("Exiting"); - System.exit(0); - } - }); + 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(); + } + }); frame.show(); animator.start(); diff --git a/src/demos/gears/Gears.java b/src/demos/gears/Gears.java index 0260ccb..94d563d 100644 --- a/src/demos/gears/Gears.java +++ b/src/demos/gears/Gears.java @@ -28,8 +28,15 @@ public class Gears { final Animator animator = new Animator(canvas); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); frame.show(); diff --git a/src/demos/jgears/JGears.java b/src/demos/jgears/JGears.java index 8229a4b..64a9f2e 100644 --- a/src/demos/jgears/JGears.java +++ b/src/demos/jgears/JGears.java @@ -28,8 +28,15 @@ public class JGears { final Animator animator = new Animator(drawable); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); frame.show(); diff --git a/src/demos/tess/Tess.java b/src/demos/tess/Tess.java index f8f8213..4063367 100644 --- a/src/demos/tess/Tess.java +++ b/src/demos/tess/Tess.java @@ -77,8 +77,15 @@ public class Tess { final Animator animator = new Animator(canvas); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); frame.show(); diff --git a/src/demos/testContextDestruction/TestContextDestruction.java b/src/demos/testContextDestruction/TestContextDestruction.java index f35a802..3adb73c 100755 --- a/src/demos/testContextDestruction/TestContextDestruction.java +++ b/src/demos/testContextDestruction/TestContextDestruction.java @@ -158,8 +158,15 @@ public class TestContextDestruction { final Animator animator = new Animator(canvas); WindowListener windowListener = new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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); diff --git a/src/demos/vertexArrayRange/VertexArrayRange.java b/src/demos/vertexArrayRange/VertexArrayRange.java index 825c668..3534c64 100644 --- a/src/demos/vertexArrayRange/VertexArrayRange.java +++ b/src/demos/vertexArrayRange/VertexArrayRange.java @@ -236,8 +236,15 @@ public class VertexArrayRange { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); diff --git a/src/demos/vertexBufferObject/VertexBufferObject.java b/src/demos/vertexBufferObject/VertexBufferObject.java index 8a697f1..78e10a9 100644 --- a/src/demos/vertexBufferObject/VertexBufferObject.java +++ b/src/demos/vertexBufferObject/VertexBufferObject.java @@ -231,8 +231,15 @@ public class VertexBufferObject { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); diff --git a/src/demos/vertexProgRefract/VertexProgRefract.java b/src/demos/vertexProgRefract/VertexProgRefract.java index 9698413..5e8f626 100644 --- a/src/demos/vertexProgRefract/VertexProgRefract.java +++ b/src/demos/vertexProgRefract/VertexProgRefract.java @@ -87,8 +87,15 @@ public class VertexProgRefract { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); diff --git a/src/demos/vertexProgWarp/VertexProgWarp.java b/src/demos/vertexProgWarp/VertexProgWarp.java index c4a88bb..3361755 100644 --- a/src/demos/vertexProgWarp/VertexProgWarp.java +++ b/src/demos/vertexProgWarp/VertexProgWarp.java @@ -84,8 +84,15 @@ public class VertexProgWarp { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - animator.stop(); - System.exit(0); + // 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(); } }); -- cgit v1.2.3