Hi all,
I have a small piece of code that shows a canvas with JavaFX.
I want to display the canvas on the second screen.
This works well in Windows but not on Linux Ubuntu.
Stage stage =new Stage(); Group root =new Group(); Scene s =new Scene(root, 1920,
1080, Color.BLACK); GraphicsContext gc; Canvas canvas =new Canvas(1920,1080); gc =
canvas.getGraphicsContext2D(); canvas.setFocusTraversable(true); // Hide canvas on
key pressed canvas.setOnKeyPressed(t -> {
stage.setFullScreen(false); stage.hide(); }); drawThings(gc);
root.getChildren().add(canvas); stage.setScene(s); // Show canvas on the second
display Rectangle2D bounds = Screen.getScreens().get(1).getVisualBounds();
stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.show();
stage.setFullScreen(true);
On Linux the canvas is shown on the first screen.
I have tried swapping the screen index from
// Show canvas on the second display Rectangle2D bounds =
Screen.getScreens().get(1).getVisualBounds();
to
// Show canvas on the second display Rectangle2D bounds =
Screen.getScreens().get(0).getVisualBounds();
but same problem.
Any idea?
Thank you
Davide