static int fixInternalFrame_border = 20; static JInternalFrame fixInternalFrame(JInternalFrame f) { Container c = f.getParent(); if (c == null) ret f; Rect r = toRect(f.getBounds()); int b = fixInternalFrame_border; Rectangle outer = shrinkRect(new Rect(0, 0, c.getWidth(), c.getHeight(), b); if (!rectsIntersect(r, outer)) f.setLocation( max(b, min(r.x, outer.x)), max(b, min(r.y, outer.y))); ret f; }