import sun.lwawt.LWWindowPeer; import javax.swing.*; import java.awt.*; public class Test { static Frame window = null; static Point pt = null; public static void main(String args[]) { try { EventQueue.invokeAndWait(() -> { window = new Frame(); window.setUndecorated(true); window.add(new JButton()); window.setSize(300,300); int dx = 0, dy = 0; GraphicsConfiguration gc = window.getGraphicsConfiguration(); Rectangle gcBounds = gc.getBounds(); Dimension windowSize = window.getSize(); gcBounds = gc.getBounds(); dx = gcBounds.x + (gcBounds.width - windowSize.width) / 2; dy = gcBounds.y + (gcBounds.height - windowSize.height) / 2; window.setLocation(dx, dy); window.setVisible(true); }); try { Thread.sleep(3000); } catch (Exception e) {} EventQueue.invokeAndWait(() -> { pt = window.getLocationOnScreen(); }); System.out.println(window); System.out.println(((LWWindowPeer)window.getPeer()).getBounds()); System.out.println(pt); }catch(Exception exx) { } } }