/** * 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; } } } } }
public void mouseMoved( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { current = getDividerNode( e.getX(), e.getY() ); if( current == null ) setCursor( null ); else if( current.getOrientation() == Orientation.HORIZONTAL ) setCursor( Cursor.getPredefinedCursor( Cursor.W_RESIZE_CURSOR ) ); else setCursor( Cursor.getPredefinedCursor( Cursor.N_RESIZE_CURSOR ) ); if( current != null ) { bounds = current.getDividerBounds( current.getActualDivider(), bounds ); deltaX = bounds.width / 2 + bounds.x - e.getX(); deltaY = bounds.height / 2 + bounds.y - e.getY(); // mouse is over divider withinBounds = true; } else { // mouse is not over divider anymore withinBounds = false; } } }
public void mouseMoved( MouseEvent e ){ if( station.isResizingEnabled() && !station.isDisabled() ) { current = getDividerNode( e.getX(), e.getY() ); if( current == null ) setCursor( null ); else if( current.getOrientation() == Orientation.HORIZONTAL ) setCursor( Cursor.getPredefinedCursor( Cursor.W_RESIZE_CURSOR ) ); else setCursor( Cursor.getPredefinedCursor( Cursor.N_RESIZE_CURSOR ) ); if( current != null ) { bounds = current.getDividerBounds( current.getActualDivider(), bounds ); deltaX = bounds.width / 2 + bounds.x - e.getX(); deltaY = bounds.height / 2 + bounds.y - e.getY(); // mouse is over divider withinBounds = true; } else { // mouse is not over divider anymore 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(); } } }
/** * Disposes all resources that are used by this handler. */ public void destroy(){ if( container != null ){ setCursor( null ); current = null; container.removeMouseListener( this ); container.removeMouseMotionListener( this ); container = null; try { java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(this); } catch (Throwable e) { e.printStackTrace(); } setController( null ); station.removeDockHierarchyListener( this ); } }
/** * Disposes all resources that are used by this handler. */ public void destroy(){ if( container != null ){ setCursor( null ); current = null; container.removeMouseListener( this ); container.removeMouseMotionListener( this ); container = null; try { java.awt.Toolkit.getDefaultToolkit().removeAWTEventListener(this); } catch (Throwable e) { e.printStackTrace(); } setController( null ); station.removeDockHierarchyListener( this ); } }
@Override public void mouseExited( MouseEvent e ){ if( !pressed ) { current = null; setCursor( null ); // mouse exited divider normally withinBounds = false; } }
@Override public void mouseExited( MouseEvent e ){ if( !pressed ) { current = null; setCursor( null ); // mouse exited divider normally withinBounds = false; } }