I wrote a small behavior that responds to key
pressing however I have to click with the mouse once on the
canvas so the behavior can become active.
Is there a way to skip the mouse
click.?
Bassam
public class MyBehavior extends Behavior{ WakeupOr waitEvent ; WakeupCriterion[] conditions = new WakeupCriterion[2]; public MyBehavior (TransformGroup tg){ super(); conditions[0] = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED); conditions[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED); } public void initialize(){ waitEvent = new WakeupOr(conditions); this.wakeupOn(waitEvent); } public void processStimulus(java.util.Enumeration e) { while (e.hasMoreElements()) { WakeupOnAWTEvent AWTevent = (WakeupOnAWTEvent) e.nextElement(); if (AWTevent ==conditions[0]) System.out.println("key pressed"); else if (AWTevent ==conditions[1]) System.out.println("mouse moved"); } this.wakeupOn(waitEvent); }} |
- Re: [JAVA3D] KeyEvent.KEY_PRESSED Bassam
- Re: [JAVA3D] KeyEvent.KEY_PRESSED Paul Adamson