/Users/lyon/j4p/src/graphics/Screen.java

1    package graphics; 
2     
3    import java.awt.*; 
4     
5     
6    public class Screen { 
7     
8        public static int getDpi() { 
9            Toolkit t = 
10                   Toolkit.getDefaultToolkit(); 
11           return t.getScreenResolution(); 
12       } 
13    
14       public static Dimension getSize() { 
15           Toolkit t = Toolkit.getDefaultToolkit(); 
16           return t.getScreenSize(); 
17       } 
18    
19       public static void main(String args[]) { 
20           System.out.println("DPI=" + getDpi()); 
21           java.awt.Dimension d = getSize(); 
22           System.out.println("size in pixels (width,height)= (" 
23                   + d.width + "," + d.height + ")"); 
24       } 
25    
26   }