Here you can find the source of getCenteringFrame()
public static Frame getCenteringFrame()
//package com.java2s; // it under the terms of the GNU General Public License as published by // import javax.swing.*; import java.awt.*; public class Main { private static JComponent COMPONENT = null; public static Frame getCenteringFrame() { for (Container c = COMPONENT; c != null; c = c.getParent()) { if (c instanceof Frame) { return (Frame) c; }/*from ww w . j av a 2s . co m*/ } return null; } }