@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
Sheet sheet = (Sheet)getComponent();
Display display = sheet.getDisplay();
Point location = sheet.mapPointToAncestor(display, x, y);
// Pretend that the mouse can't move off screen (off the display)
location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1),
Math.min(Math.max(location.y, 0), display.getHeight() - 1));
if (resizeOffset != null) {
// Resize the frame
int preferredWidth = -1;
int preferredHeight = -1;
boolean preferredWidthSet = component.isPreferredWidthSet();
boolean preferredHeightSet = component.isPreferredHeightSet();
boolean noPreferredSet = !(preferredWidthSet || preferredHeightSet);
if (preferredWidthSet || noPreferredSet) {
preferredWidth = Math.max(location.x - sheet.getX() + resizeOffset.x, 2);
preferredWidth = Math.min(preferredWidth, sheet.getMaximumPreferredWidth());
preferredWidth = Math.max(preferredWidth, sheet.getMinimumPreferredWidth());
}
if (preferredHeightSet || noPreferredSet) {
preferredHeight = Math.max(location.y - sheet.getY() + resizeOffset.y,
resizeHandle.getHeight() + 7);
preferredHeight = Math.min(preferredHeight, sheet.getMaximumPreferredHeight());
preferredHeight = Math.max(preferredHeight, sheet.getMinimumPreferredHeight());
}
sheet.setPreferredSize(preferredWidth, preferredHeight);
}
} else {
Cursor cursor = null;
Bounds resizeHandleBounds = resizeHandle.getBounds();