Javafx multiple screens fullScreen

0

I have made an application that by clicking on a button, creates in case the pc has another monitor connected, a stage fullscreen in said monitor, Now the question is, it will be possible that when the stage that this fullscreen loses the focus , the taskbar of the operating system does not go ahead of the app? ...

    
asked by Rafael Mayor 11.04.2018 в 14:45
source

1 answer

0

One possible solution would be:

First we need the identification of the primary monitor:

int primaryMon;
Screen primary = Screen.getPrimary();
for(int i = 0; i < Screen.getScreens().size(); i++){
    if(Screen.getScreens().get(i).equals(primary)){
        primaryMon = i;
        System.out.println("primary: " + i);
        break;
    }
}

After this we initiate and show the primary stage. It is important to do this on the main monitor (to hide taskbars and things like that).

Screen screen2 = Screen.getScreens().get(primaryMon);
Stage stage2 = new Stage();
stage2.setScene(new Scene(new Label("primary")));
//tenemos que establecer la posición de la ventana en el monitor principal:
stage2.setX(screen2.getVisualBounds().getMinX());
stage2.setY(screen2.getVisualBounds().getMinY());
stage2.setFullScreen(true);
stage2.show();

Now the part of the solution. We create the stages for the other monitors:

Label label = new Label("monitor " + i);
stage.setScene(new Scene(label));
System.out.println(Screen.getScreens().size());
Screen screen = Screen.getScreens().get(i); //i es el id del monitor

//establecer la posición a uno de los "slave" -monitores:
stage.setX(screen.getVisualBounds().getMinX());
stage.setY(screen.getVisualBounds().getMinY());

//establecer las dimensiones para el tamaño de la pantalla:
stage.setWidth(screen.getVisualBounds().getWidth());
stage.setHeight(screen.getVisualBounds().getHeight());

//muestra el escenario sin decoraciones (barra de título y bordes de ventana):
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
    
answered by 11.04.2018 / 14:59
source