void (@NotNull MouseEvent event, @NotNull Point targetScreenPoint, @NotNull Point startPointScreen) { if (!myTabs.isTabDraggingEnabled() || !isDragSource(event) || !MouseDragHelper.checkModifiers(event)) return; SwingUtilities.convertPointFromScreen(startPointScreen, myTabs); if (isDragJustStarted()) { TabLabel pressedTabLabel = SoftReference.dereference(myPressedTabLabel); if (pressedTabLabel == null) return; final Rectangle labelBounds = pressedTabLabel.getBounds(); myHoldDelta = new Dimension(startPointScreen.x - labelBounds.x, startPointScreen.y - labelBounds.y); myDragSource = pressedTabLabel.getInfo(); dragRec = new Rectangle(startPointScreen, labelBounds.getSize()); myDragOriginalRec = (Rectangle)dragRec.clone(); myDragOriginalRec.x -= myHoldDelta.width; myDragOriginalRec.y -= myHoldDelta.height; TabInfo.DragDelegate delegate = myDragSource.getDragDelegate(); if (delegate != null) { delegate.dragStarted(event); } } else { if (dragRec == null) return; final Point toPoint = SwingUtilities.convertPoint(event.getComponent(), event.getPoint(), myTabs); dragRec.x = toPoint.x; dragRec.y = toPoint.y; } dragRec.x -= myHoldDelta.width; dragRec.y -= myHoldDelta.height; final Rectangle headerRec = myTabs.getLastLayoutPass().getHeaderRectangle(); ScreenUtil.moveToFit(dragRec, headerRec, null); int deadZoneX = 0; int deadZoneY = 0; final TabLabel top = findLabel(new Point(dragRec.x + dragRec.width / 2, dragRec.y + deadZoneY)); final TabLabel bottom = findLabel(new Point(dragRec.x + dragRec.width / 2, dragRec.y + dragRec.height - deadZoneY)); final TabLabel left = findLabel(new Point(dragRec.x + deadZoneX, dragRec.y + dragRec.height / 2)); final TabLabel right = findLabel(new Point(dragRec.x + dragRec.width - deadZoneX, dragRec.y + dragRec.height / 2)); TabLabel targetLabel; if (myTabs.isHorizontalTabs()) { targetLabel = findMostOverlapping(Axis.X, left, right); if (targetLabel == null) { targetLabel = findMostOverlapping(Axis.Y, top, bottom); } } else { targetLabel = findMostOverlapping(Axis.Y, top, bottom); if (targetLabel == null) { targetLabel = findMostOverlapping(Axis.X, left, right); } } if (targetLabel != null) { Rectangle saved = dragRec; dragRec = null; myTabs.reallocate(myDragSource, targetLabel.getInfo()); myDragOriginalRec = myTabs.getInfoToLabel().get(myDragSource).getBounds(); dragRec = saved; myTabs.moveDraggedTabLabel(); } else { myTabs.moveDraggedTabLabel(); final int border = myTabs.getBorderThickness(); headerRec.x -= border; headerRec.y -= border; headerRec.width += border * 2; headerRec.height += border * 2; myTabs.repaint(headerRec); } event.consume(); }