Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具包
Dimension screenSize = kit.getScreenSize(); // 获取屏幕的尺寸
int screenWidth = screenSize.width / 2; // 获取屏幕的宽
int screenHeight = screenSize.height / 2; // 获取屏幕的高
int height = this.getHeight();
int width = this.getWidth();
setLocation(screenWidth - width / 2, screenHeight - height / 2);