void doHandleJavaMouseEvent(MouseEvent mouseEvent){
  if (!XToolkit.isLeftMouseButton(mouseEvent) && !XToolkit.isRightMouseButton(mouseEvent)) {
    return;
  }
  XBaseWindow grabWindow=XAwtState.getGrabWindow();
  Point ptGlobal=mouseEvent.getLocationOnScreen();
  if (!hasPointerMoved) {
    if (grabInputPoint == null || (Math.abs(ptGlobal.x - grabInputPoint.x) > getMouseMovementSmudge()) || (Math.abs(ptGlobal.y - grabInputPoint.y) > getMouseMovementSmudge())) {
      hasPointerMoved=true;
    }
  }
  XBaseMenuWindow wnd=getMenuWindowFromPoint(ptGlobal);
  XMenuItemPeer item=(wnd != null) ? wnd.getItemFromPoint(wnd.toLocal(ptGlobal)) : null;
  XBaseMenuWindow cwnd=getShowingLeaf();
switch (mouseEvent.getID()) {
case MouseEvent.MOUSE_PRESSED:
    showingMousePressedSubmenu=null;
  if ((grabWindow == this) && (wnd == null)) {
    ungrabInput();
  }
 else {
    grabInput();
    if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
      if (wnd.getShowingSubmenu() == item) {
        showingMousePressedSubmenu=(XMenuPeer)item;
      }
      wnd.selectItem(item,true);
    }
 else {
      if (wnd != null) {
        wnd.selectItem(null,false);
      }
    }
  }
break;
case MouseEvent.MOUSE_RELEASED:
if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
if (item instanceof XMenuPeer) {
  if (showingMousePressedSubmenu == item) {
    if (wnd instanceof XMenuBarPeer) {
      ungrabInput();
    }
 else {
      wnd.selectItem(item,false);
    }
  }
}
 else {
  item.action(mouseEvent.getWhen());
  ungrabInput();
}
}
 else {
if (hasPointerMoved || (wnd instanceof XMenuBarPeer)) {
  ungrabInput();
}
}
showingMousePressedSubmenu=null;
break;
case MouseEvent.MOUSE_DRAGGED:
if (wnd != null) {
if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
if (grabWindow == this) {
wnd.selectItem(item,true);
}
}
 else {
wnd.selectItem(null,false);
}
}
 else {
if (cwnd != null) {
cwnd.selectItem(null,false);
}
}
break;
}
}

void doHandleJavaMouseEvent ( MouseEvent mouseEvent ) { if ( ! XToolkit . isLeftMouseButton ( mouseEvent ) && ! XToolkit . isRightMouseButton ( mouseEvent ) ) { return ; } XBaseWindow grabWindow = XAwtState . getGrabWindow ( ) ; Point ptGlobal = mouseEvent . getLocationOnScreen ( ) ; if ( ! hasPointerMoved ) { if ( grabInputPoint == null || ( Math . abs ( ptGlobal . x - grabInputPoint . x ) > getMouseMovementSmudge ( ) ) || ( Math . abs ( ptGlobal . y - grabInputPoint . y ) > getMouseMovementSmudge ( ) ) ) { hasPointerMoved = true ; } } XBaseMenuWindow wnd = getMenuWindowFromPoint ( ptGlobal ) ; XMenuItemPeer item = ( wnd != null ) ? wnd . getItemFromPoint ( wnd . toLocal ( ptGlobal ) ) : null ; XBaseMenuWindow cwnd = getShowingLeaf ( ) ; switch ( mouseEvent . getID ( ) ) { case MouseEvent . MOUSE_PRESSED : showingMousePressedSubmenu = null ; if ( ( grabWindow == this ) && ( wnd == null ) ) { ungrabInput ( ) ; } else { grabInput ( ) ; if ( item != null && ! item . isSeparator ( ) && item . isTargetItemEnabled ( ) ) { if ( wnd . getShowingSubmenu ( ) == item ) { showingMousePressedSubmenu = ( XMenuPeer ) item ; } wnd . selectItem ( item , true ) ; } else { if ( wnd != null ) { wnd . selectItem ( null , false ) ; } } } break ; case MouseEvent . MOUSE_RELEASED : if ( item != null && ! item . isSeparator ( ) && item . isTargetItemEnabled ( ) ) { if ( item instanceof XMenuPeer ) { if ( showingMousePressedSubmenu == item ) { if ( wnd instanceof XMenuBarPeer ) { ungrabInput ( ) ; } else { wnd . selectItem ( item , false ) ; } } } else { item . action ( mouseEvent . getWhen ( ) ) ; ungrabInput ( ) ; } } else { if ( hasPointerMoved || ( wnd instanceof XMenuBarPeer ) ) { ungrabInput ( ) ; } } showingMousePressedSubmenu = null ; break ; case MouseEvent . MOUSE_DRAGGED : if ( wnd != null ) { if ( item != null && ! item . isSeparator ( ) && item . isTargetItemEnabled ( ) ) { if ( grabWindow == this ) { wnd . selectItem ( item , true ) ; } } else { wnd . selectItem ( null , false ) ; } } else { if ( cwnd != null ) { cwnd . selectItem ( null , false ) ; } } break ; } }
performs handling of java mouse event note that this function should be invoked only from root of menu window ' s hierarchy that grabs input focus
