try to use
JFrame.setLocationRelativeTo(Componenet);
JFrame.setLocationByPlatform(boolean locationByPlatform);
you can learn it from java api
导入这两个包import java.awt.Dimension;import java.awt.Toolkit;
Dimension dimension=kit.getScreenSize();//获取屏幕大小
int width=dimension.width;
int height=dimension.height;
int x=(width-WIDTH)/2;
int y=(height-HEIGHT)/2;
frame.setLocation(x, y);