1、代码:
java.awt.Toolkit tk=java.awt.Toolkit.getDefaultToolkit();
java.awt.Dimension screenSize=tk.getScreenSize();
int screenWidth=screenSize.width;
//System.out.println(screenWidth);//1440
int screenHeight=screenSize.height;
//System.out.println(screenHeight);//900
简化:
Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
System.out.println(screen.width);