How to find number of displays

Is there a way to find out how many displays are available to my Processing program?

I would like my sketch to start in fullScreen on display 2 if it is connected, otherwise display 1. Currently, I’m using fullScreen(2) and it gives a warning if there is no display 2, but still works. I’d like to avoid the warning, if possible, by checking for the presence of display 2 before I go fullScreen on it.

1 Like

You can have a look at the source code and implement a solution for your use case. Points of interest in the source code:

The last link shows that you can specify a parameter when running your sketch. It could be handy in certain scenarios as for example, if your code was an executable.


1 Like
  • @kfrajer, avoid linking the master branch when using links w/ #L. :warning:
  • B/c it’s constantly being worked on, the line number isn’t gonna be the same for long. :construction_worker_man:
  • Instead, link to a specific tag branch, b/c it’s frozen forever. :ice_cube:
1 Like

Excellent, thanks! The GraphicsEnvironment (with GraphicsDevice[] list) gives me exactly what I need.