Code example of using multiple displays, kiosk mode etc?


I’m new to JUCE and would love to see some example code of how to use the desktop and displays classes to have my app run exclusively in a particular screen of a multiple monitor workstation.
All the functionality seems to be present in the classes, but it would be incredibly helpful to see them in action in an even vaguely similar application.
Many thanks


So the following code in JUCEApplication derived class identifies all the monitors connected to the workstation but how do I select the one I have identified to be the apps dedicated display screen?

 void initialise(const String& commandLine) override
    		mainWindow.reset(new MainWindow(getApplicationName()));
    		auto Ndisplays = Desktop::getInstance().getDisplays().displays;
    		DBG("Array size " << Ndisplays.size());
    		for (int i = 0; i < Ndisplays.size(); i++) {
    			DBG("n=" << i);
	void DBdisplay(Desktop::Displays::Display disp) {
		DBG("Scale is: " << disp.scale);
		DBG("isMain " << (int)disp.isMain);
		DBG("totalArea W " << disp.totalArea.getWidth());
		DBG("totalArea H " << disp.totalArea.getHeight());
		DBG("DPI is: " << disp.dpi);


The display has the public Rectangle userArea or totalArea. Since they are rectangle, they don’t overlap. Instead of setSize() you can call setBounds instead.
In the boilerplate of main.cpp, you can change the
centreWithSize (getWidth(), getHeight()); into

const auto& display = Desktop::getInstance().getDisplays().displays.getLast();
setBounds (display.userArea.withSizeKeepingCentre (300, 100));


thanks so much:+1: