@Override
		protected void dispatchEvent( AWTEvent e ) {
			int id = e.getID();

			if( e instanceof MouseEvent &&
				(id == MouseEvent.MOUSE_MOVED || id == MouseEvent.MOUSE_DRAGGED) )
			{
				newMouseX = ((MouseEvent)e).getXOnScreen();
				newMouseY = ((MouseEvent)e).getYOnScreen();

				if( safeTrianglePainter != null )
					safeTrianglePainter.repaint();

				mouseUpdateTimer.stop();
				timeoutTimer.stop();

				// check whether mouse moved within safe triangle
				if( createSafeTriangle().contains( newMouseX, newMouseY ) ) {
					// update mouse location delayed (this changes the safe triangle)
					mouseUpdateTimer.start();

					timeoutTimer.start();

					// remember last mouse event, which will be posted if the mouse stops moving
					lastMouseEvent = e;

					// ignore mouse event
					return;
				}

				// update mouse location immediately (this changes the safe triangle)
				mouseX = newMouseX;
				mouseY = newMouseY;
			}

			super.dispatchEvent( e );
		}
Improves usability of submenus by using a
<a href="https://height.app/blog/guide-to-build-context-menus#safe-triangle">safe triangle</a>
to avoid that the submenu closes while the user moves the mouse to it.

@author Karl Tauber
flatlaf-core/src/main/java/com/formdev/flatlaf/SubMenuUsabilityHelper.java