Import Java. AWT. point; import Java. AWT. rectangle; import Java. AWT. event. actionevent; import Java. AWT. event. actionlistener; import javax. swing. jframe; import javax. swing. timer; public class myframe extends jframe implements actionlistener {private rectangle rect; // The distance between the form and the left of the screen is private int left; // The distance between the form and the top of the screen is private int top; // form width private int width; // form height private int height; // place the cursor in the form private point Point; private timer = new timer (10, this); Public myframe () {timer. start ();} public void actionreceivmed (actionevent e) {left = getlocationonscreen (). x; Top = getlocationonscreen (). y; width = getwidth (); Height = getheight (); // obtain the form profile rect = new rectangle (0, 0, width, height ); // obtain the cursor position in the Form. Point = getmouseposition (); If (top <0) & isptinrect (rect, point) {// when the cursor is in the current form, and the top attribute of the form. Less than 0 // set the top attribute of the form to 0, that is, to close the upper edge of the window to the top setlocation (left, 0 );} else if (top>-5 & Top <5 &&! (Isptinrect (rect, point) {// when the distance between the upper border of the form and the top of the screen is less than 5, // and the mouse does not hide the QQ form to the top of the screen. setlocation (left, 5-height );}} /*** determine whether a vertex is in a rectangle ** @ Param rect: rectangle object * @ Param point: Point Object * @ return: if true is returned in a rectangle, false */Public Boolean isptinrect (rectangle rect, point) {If (rect! = NULL & point! = NULL) {int X0 = rect. x; int Y0 = rect. y; int X1 = rect. width; int Y1 = rect. height; int x = point. x; int y = point. y; return x> = x0 & x <X1 & Y> = y0 & Y <Y1;} return false;} public static void main (string [] ARGs) {myframe frame = new myframe (); frame. settitle ("test"); frame. setsize (400,300); frame. setlocation (400,300); frame. setvisible (true); frame. setdefaclocloseoperation (jframe. exit_on_close );}}