Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

recieving press MouseEvents immediately after release MouseEvents

843799Jan 15 2010 — edited Jun 22 2010
When I release the mouse with this code, it receives a MouseEvent that says it's released, and then immediately afterward one that says it's been pressed again.

This is the code that processes the press events... (I am fully aware of how awful it is):
    public void processStimulus(Enumeration criteria) {
...
            if( !editBehavior.existsSelectedLocatable()){
                while(criteria.hasMoreElements()){
                    WakeupCriterion i= (WakeupCriterion) criteria.nextElement();
                    if(i instanceof WakeupOnAWTEvent){
                        AWTEvent[] events = ((WakeupOnAWTEvent)i).getAWTEvent();
                        for (AWTEvent j: events){
                            if(j instanceof MouseEvent){
                                MouseEvent mevt = (MouseEvent)j;
                                if (mevt.getButton() == MouseEvent.BUTTON1 &&
                                      mevt.getID() == MouseEvent.MOUSE_PRESSED &&
                                      (mevt.getModifiers() & InputEvent.BUTTON1_MASK)
                                      == InputEvent.BUTTON1_MASK){
                                    PickResult result = pickPelvic();
                                    if (result != null){
                                        System.out.print("mouse event "+  mevt);
                                        Node shape = result.getNode(PickResult.SHAPE3D);
                                        Instrument instrument = (Instrument) shape.getUserData();
                                        instrument.selectLeftClick();
                                        mevt.consume();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        wakeupOn(condition);
    }
and this is the code that processes release events:
    public void processStimulus(Enumeration criteria) {
        if (manager.isEditMode()){
            while(criteria.hasMoreElements()){
                WakeupCriterion i= (WakeupCriterion) criteria.nextElement();
                if(i instanceof WakeupOnAWTEvent){
                    AWTEvent[] events = ((WakeupOnAWTEvent)i).getAWTEvent();
                    for (AWTEvent j: events){
                        if (j instanceof KeyEvent){

...
                        }else if(j instanceof MouseEvent){
                            MouseEvent mevt = (MouseEvent)j;
                            if (mevt.getButton() == MouseEvent.BUTTON1 && 
                                    mevt.getID() == MouseEvent.MOUSE_RELEASED 
                                    && instrument != null){
                                System.out.print("mouse event " + mevt);
                                releaseInstrument();
                                ((MouseEvent)j).consume();
                            }
                        }
                    }
                }
            }
            if(instrument instanceof Locatable){
                computePosition();
            }
        }
        wakeupOn(condition); 
    }
I'm not sure what I'm doing to cause the spurious press events.

Comments

843799
As concerning this topic - well, I know that
a lot of [resume services|http://cvresumewritingservices.org/] advise including this into your cv
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 20 2010
Added on Jan 15 2010
1 comment
148 views