GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
try {
GraphicsDevice[] gs = ge.getScreenDevices();
// récupération du nombre d'écrans
int screenNumber = gs.length;
System.out.println(screenNumber);
} catch (Exception e) {
//si il n'y a pas d'écrans...
e.printStackTrace();
}