void (Object component, int x, int y, int width, int height) { Rectangle view = getRectangle(component, ":view"); Rectangle port = getRectangle(component, ":port"); int vx = Math.max(x + width - port.width + 2, Math.min(view.x, x)); int vy = Math.max(y + height - port.height + 2, Math.min(view.y, y)); if ((view.x != vx) || (view.y != vy)) { repaint(component); // horizontal | vertical view.x = vx; view.y = vy; } }