/** * AWT event listener. * Used to reset the mouse cursor when divider was changed and mouse exited event had not occurred normally. * @param event */ public void eventDispatched(AWTEvent event) { if (event.getID() == MouseEvent.MOUSE_MOVED || event.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent mev = (MouseEvent)event; if( mev.getSource() != Handler.this.container && withinBounds ){ if( mev.getSource() instanceof GlassedPane.GlassPane ){ // on glass pane -> check with traditional method // Question by Beni: does this ever happen? checkMousePositionAsync(); } else{ // mouse is over another component which is not the registered container and the mouse cursor had not been reseted yet -> reset mouse cursor Point p = SwingUtilities.convertPoint(mev.getComponent(), mev.getPoint(), station); if (station.getBounds().contains(p)) { // only if mouse is within our station setCursor(null); withinBounds = false; } } } } }
/** * AWT event listener. * Used to reset the mouse cursor when divider was changed and mouse exited event had not occurred normally. * @param event */ public void eventDispatched(AWTEvent event) { if (event.getID() == MouseEvent.MOUSE_MOVED || event.getID() == MouseEvent.MOUSE_RELEASED) { MouseEvent mev = (MouseEvent)event; if( mev.getSource() != Handler.this.container && withinBounds ){ if( mev.getSource() instanceof GlassedPane.GlassPane ){ // on glass pane -> check with traditional method // Question by Beni: does this ever happen? checkMousePositionAsync(); } else{ // mouse is over another component which is not the registered container and the mouse cursor had not been reseted yet -> reset mouse cursor Point p = SwingUtilities.convertPoint(mev.getComponent(), mev.getPoint(), station); if (station.getBounds().contains(p)) { // only if mouse is within our station setCursor(null); withinBounds = false; } } } } }
@Override public void mouseReleased( MouseEvent e ){ if( pressed ) { pressed = false; if( current != null ) { setDivider( current, divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); station.updateBounds(); } setCursor( null ); mouseMoved( e ); if( controller != null && !controller.isRestrictedEnvironment() && awtListenerEnabled ) { // new solution eventDispatched(e); } else { // old solution with a little tweaking checkMousePositionAsync(); } } }
@Override public void mouseReleased( MouseEvent e ){ if( pressed ) { pressed = false; if( current != null ) { setDivider( current, divider ); repaint( bounds.x, bounds.y, bounds.width, bounds.height ); station.updateBounds(); } setCursor( null ); mouseMoved( e ); if( controller != null && !controller.isRestrictedEnvironment() && awtListenerEnabled ) { // new solution eventDispatched(e); } else { // old solution with a little tweaking checkMousePositionAsync(); } } }