import java.awt.Dimension;标签:居中,...,JFrame,Java,java,screenSize,myJFrame,import,Dimension From: https://blog.51cto.com/softo/6022985
import java.awt.Toolkit;
import javax.swing.JFrame;
public class getScreenSize {
public static void main(String[] args) {
//获取屏幕大小
Dimension screenSize =Toolkit.getDefaultToolkit().getScreenSize();
JFrame myJFrame =new JFrame("2011.12.04 Sunday By friendan!");
myJFrame.setSize(400,300);
//让窗口居中显示
myJFrame.setLocation(screenSize.width/2-400/2,screenSize.height/2-300/2);
//...
myJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myJFrame.setVisible(true);
}
}