summaryrefslogtreecommitdiffstats
path: root/src/demos
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos')
-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 ..