/** * Returns the insets that should be used to calculate the resize area. Unless you have used setResizeInsets or * overridden this method, it'll return the insets of the component. * * @return the insets that should be used to calculate the resize area. */ public Insets getResizeInsets() { if (_resizeInsets != null) { return _resizeInsets; } return getComponent().getInsets(); }
@Override public void mouseExited(MouseEvent e) { if (e.getSource() instanceof Resizable.ResizeCorner) { Resizable.ResizeCorner corner = (Resizable.ResizeCorner) e.getSource(); corner.setCursor(Cursor.getDefaultCursor()); } else { _resizable.getComponent().setCursor(Cursor.getDefaultCursor()); } } }
else if (e.getSource() == _resizable.getComponent()) { Insets i = _resizable.getResizeInsets(); boolean ltr = _resizable.getComponent().getComponentOrientation().isLeftToRight(); if (e.getX() <= i.left) { if (isResizable(Resizable.UPPER_LEFT) && i.top > 0 && e.getY() < _resizable.getResizeCornerSize() + i.top) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.NW_RESIZE_CURSOR : Cursor.NE_RESIZE_CURSOR)); else if (isResizable(Resizable.LOWER_LEFT) && i.bottom > 0 && e.getY() > _resizable.getComponent().getHeight() - _resizable.getResizeCornerSize() - i.bottom) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.SW_RESIZE_CURSOR : Cursor.SE_RESIZE_CURSOR)); else if (isResizable(Resizable.LEFT)) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.W_RESIZE_CURSOR : Cursor.E_RESIZE_CURSOR)); else _resizable.getComponent().setCursor(Cursor.getDefaultCursor()); else if (e.getX() >= _resizable.getComponent().getWidth() - i.right) { if (isResizable(Resizable.UPPER_RIGHT) && i.top > 0 && e.getY() < _resizable.getResizeCornerSize() + i.top) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.NE_RESIZE_CURSOR : Cursor.NW_RESIZE_CURSOR)); else if (isResizable(Resizable.LOWER_LEFT) && i.bottom > 0 && e.getY() > _resizable.getComponent().getHeight() - _resizable.getResizeCornerSize() - i.bottom) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.SE_RESIZE_CURSOR : Cursor.SW_RESIZE_CURSOR)); else if (isResizable(Resizable.RIGHT)) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.E_RESIZE_CURSOR : Cursor.W_RESIZE_CURSOR)); else _resizable.getComponent().setCursor(Cursor.getDefaultCursor()); _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.NW_RESIZE_CURSOR : Cursor.NE_RESIZE_CURSOR)); else if (isResizable(Resizable.UPPER_RIGHT) && i.right > 0 && e.getX() > _resizable.getComponent().getWidth() - _resizable.getResizeCornerSize() - i.right) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(ltr ? Cursor.NE_RESIZE_CURSOR : Cursor.NW_RESIZE_CURSOR)); else if (isResizable(Resizable.UPPER)) _resizable.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); else
_startingBounds = _resizable.getComponent().getBounds(); if (_resizable.isTopLevel()) { Point location = new Point(_startingBounds.x, _startingBounds.y); SwingUtilities.convertPointToScreen(location, _resizable.getComponent()); _startingBounds.x = location.x; _startingBounds.y = location.y; else if (e.getSource() == _resizable.getComponent()) { Insets i = _resizable.getResizeInsets(); if (e.getX() <= i.left) { else if (i.bottom > 0 && e.getY() > _resizable.getComponent().getHeight() - _resizable.getResizeCornerSize() - i.bottom) { _resizeCorner = Resizable.LOWER_LEFT; else if (i.right > 0 && e.getX() >= _resizable.getComponent().getWidth() - i.right) { if (i.top > 0 && e.getY() < _resizable.getResizeCornerSize() + i.top) { _resizeCorner = Resizable.UPPER_RIGHT; else if (i.bottom > 0 && e.getY() > _resizable.getComponent().getHeight() - _resizable.getResizeCornerSize() - i.bottom) { _resizeCorner = Resizable.LOWER_RIGHT; else if (i.right > 0 && e.getX() > _resizable.getComponent().getWidth() - _resizable.getResizeCornerSize() - i.right) { _resizeCorner = Resizable.UPPER_RIGHT; else if (i.bottom > 0 && e.getY() >= _resizable.getComponent().getHeight() - i.bottom) { if (i.left > 0 && e.getX() < _resizable.getResizeCornerSize() + i.left) {
int deltaY = _eventMouseScreenY - p.y; Dimension min = _resizable.getComponent().getMinimumSize(); Dimension max = _resizable.getComponent().getMaximumSize(); Point point = new Point(_resizable.getComponent().getX(), _resizable.getComponent().getY()); SwingUtilities.convertPointToScreen(point, _resizable.getComponent()); : _resizable.getComponent().getParent().getBounds(); boolean ltr = _resizable.getComponent().getComponentOrientation().isLeftToRight(); if (!ltr) { switch (_resizeCorner) { Rectangle screenBounds = PortingUtils.getScreenBounds(_resizable.getComponent()); newX = Math.max(newX, screenBounds.x); newY = Math.max(newY, screenBounds.y);
Container c = _resizable.getComponent().getTopLevelAncestor(); if (c instanceof JFrame) { ((JFrame) _resizable.getComponent().getTopLevelAncestor()).getGlassPane().setCursor(Cursor.getDefaultCursor()); ((JFrame) _resizable.getComponent().getTopLevelAncestor()).getGlassPane().setVisible(false);