void (final MouseEvent e) { super.processMouseMotionEvent(e); if(MouseEvent.MOUSE_DRAGGED==e.getID() && myLastPoint != null){ final Point newPoint=e.getPoint(); SwingUtilities.convertPointToScreen(newPoint,this); Rectangle screenBounds = WindowManagerEx.getInstanceEx().getScreenBounds(); int screenMaxX = screenBounds.x + screenBounds.width; int screenMaxY = screenBounds.y + screenBounds.height; newPoint.x = MathUtil.clamp(newPoint.x, screenBounds.x, screenMaxX); newPoint.y = MathUtil.clamp(newPoint.y, screenBounds.y, screenMaxY); final Rectangle oldBounds=FloatingDecorator.this.getBounds(); final Rectangle newBounds=new Rectangle(oldBounds); if((myMotionMask&ANCHOR_TOP)>0){ newPoint.y=Math.min(newPoint.y,oldBounds.y+oldBounds.height-2*DIVIDER_WIDTH); if(newPoint.y<screenBounds.y+DIVIDER_WIDTH){ newPoint.y=screenBounds.y; } final Point offset=new Point(newPoint.x-myLastPoint.x,newPoint.y-myLastPoint.y); newBounds.y=oldBounds.y+offset.y; newBounds.height=oldBounds.height-offset.y; } if((myMotionMask&ANCHOR_LEFT)>0){ newPoint.x=Math.min(newPoint.x,oldBounds.x+oldBounds.width-2*DIVIDER_WIDTH); if(newPoint.x<screenBounds.x+DIVIDER_WIDTH){ newPoint.x=screenBounds.x; } final Point offset=new Point(newPoint.x-myLastPoint.x,newPoint.y-myLastPoint.y); newBounds.x=oldBounds.x+offset.x; newBounds.width=oldBounds.width-offset.x; } if((myMotionMask&ANCHOR_BOTTOM)>0){ newPoint.y=Math.max(newPoint.y,oldBounds.y+2*DIVIDER_WIDTH); if (newPoint.y > screenMaxY - DIVIDER_WIDTH) { newPoint.y = screenMaxY; } final Point offset=new Point(newPoint.x-myLastPoint.x,newPoint.y-myLastPoint.y); newBounds.height=oldBounds.height+offset.y; } if((myMotionMask&ANCHOR_RIGHT)>0){ newPoint.x=Math.max(newPoint.x,oldBounds.x+2*DIVIDER_WIDTH); if (newPoint.x > screenMaxX - DIVIDER_WIDTH) { newPoint.x = screenMaxX; } final Point offset=new Point(newPoint.x-myLastPoint.x,newPoint.y-myLastPoint.y); newBounds.width=oldBounds.width+offset.x; } // It's much better to resize frame this way then via Component.setBounds() method. // Component.setBounds() method cause annoying repainting and blinking. //FloatingDecorator.this.getPeer().setBounds(newBounds.x,newBounds.y,newBounds.width,newBounds.height, 0); FloatingDecorator.this.setBounds(newBounds.x,newBounds.y,newBounds.width,newBounds.height); myLastPoint=newPoint; } else if(e.getID()==MouseEvent.MOUSE_MOVED){ if(!myDragging){ setMotionMask(e.getPoint()); } } }