Java获得屏幕分辨率
Java获得屏幕分辨率源代码如下:
1 public class Screen 2 { 3 public static void main(String[] args) 4 { 5 int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); 6 int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); 7 System.out.println(screenWidth+""+screenHeight); 8 } 9 } 10 class ScreenSize 11 { 12 private int screenWidth; 13 private int screenHeight; 14 public void setScreenWidth(int screenWidth) 15 { 16 this.screenWidth=screenWidth; 17 } 18 public void setScreenHeight(int screenHeight) 19 { 20 this.screenHeight=screenHeight; 21 } 22 public int getScreenWidth() 23 { 24 setScreenWidth((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize.width); 25 return screenWidth; 26 } 27 public int getScreenHeight() 28 { 29 setScreenHeight((int)java.awt.Toolkit.getDefaultToolkit.getScreenSize().height); 30 return screenHeight; 31 } 32 }