{
// If the frame is maximized, there is nothing that
// can be dragged around.
if (frame.isMaximum())
return;
DesktopManager dm = getDesktopManager();
Rectangle b = frame.getBounds();
Dimension min = frame.getMinimumSize();
if (min == null)
min = new Dimension(0, 0);
Insets insets = frame.getInsets();
int x = e.getX();
int y = e.getY();
if (e.getSource() == frame && frame.isResizable())
{
switch (direction)
{
case Cursor.N_RESIZE_CURSOR:
cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
- min.height),
b.width, b.height - y);
break;
case Cursor.NE_RESIZE_CURSOR:
cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
- min.height), x + 1,
b.height - y);
break;
case Cursor.E_RESIZE_CURSOR:
cacheRect.setBounds(b.x, b.y, x + 1, b.height);
break;
case Cursor.SE_RESIZE_CURSOR:
cacheRect.setBounds(b.x, b.y, x + 1, y + 1);
break;
case Cursor.S_RESIZE_CURSOR:
cacheRect.setBounds(b.x, b.y, b.width, y + 1);
break;
case Cursor.SW_RESIZE_CURSOR:
cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
b.y, b.width - x, y + 1);
break;
case Cursor.W_RESIZE_CURSOR:
cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
b.y, b.width - x, b.height);
break;
case Cursor.NW_RESIZE_CURSOR:
cacheRect.setBounds(
Math.min(b.x + x, b.x + b.width - min.width),
Math.min(b.y + y, b.y + b.height - min.height),
b.width - x, b.height - y);
break;
}
dm.resizeFrame(frame, cacheRect.x, cacheRect.y,
Math.max(min.width, cacheRect.width),
Math.max(min.height, cacheRect.height));
setCursor(e);
}
else if (e.getSource() == titlePane)
{
Rectangle fBounds = frame.getBounds();
frame.putClientProperty("bufferedDragging", Boolean.TRUE);
dm.dragFrame(frame, e.getX() - xOffset + b.x, e.getY() - yOffset
+ b.y);
}
}