Skip to Main Content

Java SE (Java Platform, Standard Edition)

new simple behavior--I think I'm doing everything right

843799Feb 15 2010 — edited Jun 13 2010
So I add this behavior to my scene graph, and I think I'm doing everything right, and the processStimulus just doesn't get called.

I think I have all the pitfalls covered:
scheduling bounds set;
added to the graph;
wakeup condition created;
wakeupon called in both initialize() and processStimulus()...

Can anyone look at my code and tell me what I'm missing?

I add the object:
        KeyBehavior keyBehavior = new KeyBehavior(locatableCallback); 
        keyBehavior.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), 
this is the behavior code:
public class KeyBehavior extends Behavior {

    private static int deleteKey;
    private WakeupOnAWTEvent condition;
    private HashMap<Integer, KeyListener> map = new HashMap<Integer, KeyListener>();
    private InstrumentManager manager;
    public KeyBehavior(KnowsSelected knows) {
        manager= InstrumentManager.getInstance();
        if (Util.isMac()){
            deleteKey = KeyEvent.VK_BACK_SPACE;
        } else {
            deleteKey = KeyEvent.VK_DELETE;
        map.put(deleteKey, new DeleteListener(knows));

    public void initialize() {
        condition = new WakeupOnAWTEvent( KeyEvent.KEY_RELEASED );

    public void processStimulus(Enumeration criteria) {
        System.out.println("got here 1");
        if (manager.isEditMode()){
            System.out.println("got here 2");
            KeyEvent kevt = (KeyEvent) ((WakeupOnAWTEvent)criteria.nextElement()).getAWTEvent()[0];
            int kevtcode = kevt.getKeyCode();
            System.out.print("key event code "+ kevtcode + " == delete "+ deleteKey+"?");
            if (map.containsKey(kevtcode)){

Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 11 2010
Added on Feb 15 2010
1 comment