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);
时间: 2024-10-24 12:36:46