static JInternalFrame centerInternalFrame(JInternalFrame f) { Container c = f.getParent(); if (c != null) { print("Container type: " + className(c) + ", bounds: " + c.getBounds()); f.setLocation((c.getWidth()-f.getWidth())/2, (c.getHeight()-f.getHeight())/2); } ret f; }