static Window moveWindowIntoScreen(final Window w) { if (w != null) swing { Rectangle s = usableWindowArea(); Rectangle r1 = w.getBounds(); Rectangle r = new Rectangle(r1); // adjust size r.width = min(r.width, s.width); r.height = min(r.height, s.height); // adjust position r.x = min(x2(s)-r.width, max(r.x, s.x)); r.y = min(y2(s)-r.height, max(r.y, s.y)); if (neq(r, r1)) w.setBounds(r); } ret w; }