How to set a JavaFX window on top of other windows, including other applications, games, and so on. I have a Linux operating system.
I need the window to be completely transparent and without a frame, and the elements in it were visible without problems. I also tried initStyle Undecorated with Modality.WINDOW_MODAL
and in this case the window stays on top of other windows of my application only. Maybe someone knows how to do what I need to do.
public void initialize() {
try {
FXMLLoader loader = new FXMLLoader(SystemScopeMain.class.getResource("BenchWidget-view.fxml"));
Parent root = loader.load();
Stage transparentStage = new Stage();
transparentStage.initStyle(StageStyle.TRANSPARENT);
Scene scene = new Scene(root, 400, 300);
scene.setFill(Color.TRANSPARENT);
transparentStage.setScene(scene);
transparentStage.setOpacity(0.4);
transparentStage.initModality(Modality.WINDOW_MODAL);
transparentStage.setAlwaysOnTop(true);
transparentStage.setX(0);
transparentStage.setY(0);
transparentStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}