Here you can find the source of alignCenter(JInternalFrame internalFrame)
public static void alignCenter(JInternalFrame internalFrame)
//package com.java2s; //License from project: Open Source License import java.awt.Point; import javax.swing.JDesktopPane; import javax.swing.JInternalFrame; public class Main { public static void alignCenter(JInternalFrame internalFrame) { JDesktopPane desktopPane = internalFrame.getDesktopPane(); int desktopWidth = desktopPane.getWidth(); int desktopHeight = desktopPane.getHeight(); int frameWidth = internalFrame.getWidth(); int frameHeight = internalFrame.getHeight(); Point newLocation = new Point((desktopWidth - frameWidth) / 2, (desktopHeight - frameHeight) / 2); internalFrame.setLocation(newLocation); }/*from w w w .j a v a 2 s . com*/ }