Mega Code Archive

 
Categories / Java / 2D Graphics GUI
 

If more than one screen is available, gets the size of each screen

import java.awt.DisplayMode; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; public class Main {   public static void main(String[] argv) throws Exception {     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();     GraphicsDevice[] gs = ge.getScreenDevices();     for (int i = 0; i < gs.length; i++) {       DisplayMode dm = gs[i].getDisplayMode();       int screenWidth = dm.getWidth();       int screenHeight = dm.getHeight();     }   } }