Here you can find the source of getRootFrame()
public static Frame getRootFrame()
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; public class Main { private static Frame frame; public static Frame getRootFrame() { if (frame == null) { frame = new Frame(); frame.setSize(Toolkit.getDefaultToolkit().getScreenSize()); positionCenterScreen(frame); }//from w w w. j a v a 2 s .c o m return frame; } public static void positionCenterScreen(Window window) { Dimension maxDimension = Toolkit.getDefaultToolkit().getScreenSize(); Dimension wSize = window.getSize(); int maxWidth = maxDimension.width; int maxHeight = maxDimension.height; // fit on window if (wSize.height > maxHeight) { wSize.height = maxHeight; } if (wSize.width > maxWidth) { wSize.width = maxWidth; } window.setSize(wSize); if (maxDimension.width != wSize.width && maxDimension.height != wSize.height) { int x = (maxDimension.width - wSize.width) / 2; int y = (maxDimension.height - wSize.height) / 2; window.setLocation(x, y); } else { if (window instanceof JFrame) { JFrame f = (JFrame) window; f.setExtendedState(JFrame.MAXIMIZED_BOTH); } else { window.setLocation(0, 0); } } window.toFront(); } }