Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screen = toolkit.getScreenSize(); x = (screen.width - this.getWidth()) / 2; y = (screen.height - this.getHeight() - 20) / 2;
转载于:https://my.oschina.net/zchuanzhao/blog/512543