Here you can find the source of center(JFrame parent, JInternalFrame dialog)
public static void center(JFrame parent, JInternalFrame dialog)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JInternalFrame; public class Main { /**//from ww w . j a v a 2s . c o m * Centers the supplied dialog in its parent's bounds. */ public static void center(JFrame parent, JInternalFrame dialog) { Dimension psize = parent.getSize(); Dimension dsize = dialog.getSize(); dialog.setLocation((psize.width - dsize.width) / 2, (psize.height - dsize.height) / 2); } }