0

I have the below demo application, which display sample text always on top:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class Demo extends Application {

    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);

 Scene scene = new Scene(root, 100, 300);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.initStyle(StageStyle.TRANSPARENT);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }
 public static void main(String[] args) {
        launch(args);
    }
}

Is it possible to show this window always on top also visible in another application (cpp video game)?

1 Answers1

0

Try primaryStage.initModality(Modality.APPLICATION_MODAL);

JavaFX 2.2 Stage always on top

Flaom
  • 134
  • 11