summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-06-15 10:18:30 +0000
committerSven Gothel <[email protected]>2009-06-15 10:18:30 +0000
commit224f777f62a8b682184d0cdf8fb8470aabf13977 (patch)
tree618c4bb7d9a832a64ccc4cc65c8f2e44e3620065 /src
parent736ed4eb312bc255b9219f60b0f66f2397019adb (diff)
RedSquare exit on key 'q' as well
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JOGL_2_SANDBOX@349 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src')
-rwxr-xr-xsrc/demos/es1/RedSquare.java3
-rwxr-xr-xsrc/demos/es2/RedSquare.java16
2 files changed, 18 insertions, 1 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index 4227418..58b5e01 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -41,6 +41,9 @@ public class RedSquare extends Thread implements WindowListener, KeyListener, Mo
public void keyPressed(KeyEvent e) {
System.out.println(glp+" "+e);
+ if(e.getKeyCode()==KeyEvent.VK_Q) {
+ quit = true;
+ }
}
public void keyReleased(KeyEvent e) {
System.out.println(glp+" "+e);
diff --git a/src/demos/es2/RedSquare.java b/src/demos/es2/RedSquare.java
index d2149bc..d1d2c5d 100755
--- a/src/demos/es2/RedSquare.java
+++ b/src/demos/es2/RedSquare.java
@@ -12,7 +12,7 @@ import com.sun.opengl.util.glsl.*;
import com.sun.javafx.newt.*;
import com.sun.javafx.newt.opengl.*;
-public class RedSquare extends Thread implements WindowListener, MouseListener, GLEventListener {
+public class RedSquare extends Thread implements WindowListener, KeyListener, MouseListener, GLEventListener {
private GLWindow window;
private GLProfile glp;
@@ -41,6 +41,19 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
quit = true;
}
+ public void keyPressed(KeyEvent e) {
+ System.out.println(glp+" "+e);
+ if(e.getKeyCode()==KeyEvent.VK_Q) {
+ quit = true;
+ }
+ }
+ public void keyReleased(KeyEvent e) {
+ System.out.println(glp+" "+e);
+ }
+ public void keyTyped(KeyEvent e) {
+ System.out.println(glp+" "+e);
+ }
+
public void mouseClicked(MouseEvent e) {
System.out.println(glp+" mouseevent: "+e);
switch(e.getClickCount()) {
@@ -85,6 +98,7 @@ public class RedSquare extends Thread implements WindowListener, MouseListener,
window.addWindowListener(this);
window.addMouseListener(this);
+ window.addKeyListener(this);
window.addGLEventListener(this);
// window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
// window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..