/** * This method is called to drag the DragWindow around when the JToolBar is being dragged around. * * @param position The mouse cursor coordinates relative to the JToolBar. * @param origin The screen position of the JToolBar. */ protected void dragTo(Point position, Point origin) { int loc = areaOfClick(origParent, SwingUtilities.convertPoint(toolBar, position, origParent)); if (loc != -1) { dragWindow.setBorderColor(dockingBorderColor); dragWindow.setBackground(dockingColor); } else { dragWindow.setBorderColor(floatingBorderColor); dragWindow.setBackground(floatingColor); } int w = 0; int h = 0; boolean tmp = (loc == SwingConstants.NORTH) || (loc == SwingConstants.SOUTH) || (loc == -1); cachedOrientation = toolBar.getOrientation(); cachedBounds = toolBar.getSize(); if (((cachedOrientation == SwingConstants.HORIZONTAL) && tmp) || ((cachedOrientation == VERTICAL) && !tmp)) { w = cachedBounds.width; h = cachedBounds.height; } else { w = cachedBounds.height; h = cachedBounds.width; } Point p = dragWindow.getOffset(); Insets insets = toolBar.getInsets(); dragWindow.setBounds( (origin.x + position.x) - p.x - ((insets.left + insets.right) / 2), (origin.y + position.y) - p.y - ((insets.top + insets.bottom) / 2), w, h); if (!dragWindow.isVisible()) dragWindow.show(); }