Home>

As the title says. Click the button to bring up a new screen, but I want to pin that screen to the front.
At first, it will come to the front as desired, but if you click the button twice, it will go to the back of the original screen.

Corresponding source code

I want to fix the screen generated from this button to the front.
I don't want the new screen to appear only once, so it's disabled unless the screen disappears after pressing the button many times.
(There is a process to set Hensu.cnt = 0 in the close button event)

void On_buttonF3_Ndenpyo (ActionEvent event) {
// Only one search window
        if (Hensu.cnt! = 1) {
       /*
         * Generate a new screen
         * /
        try {
            Parent parent = FXMLLoader.load (getClass (). GetResource ("Kensaku.fxml"));
            Scene scene = new Scene (parent);
            Stage stage = new Stage ();
            stage.setScene (scene);
            stage.setTitle ("Voucher Search");
            stage.show ();
            Hensu.cnt = 1;
        } catch (IOException e) {
            e.printStackTrace ();
        }
        }
}
What I tried

setAlwaysOnTop ()
toFront ()
I knew that I could use it, but I don't know how to use it. Where should I add it if I use it?

  • Answer # 1

    I don't know how to use it.

    I don't know where you saw it, but when I googled "JavaFX setAlwaysOnTop", the official documentation came out first.
    Stage (JavaFX 8)

    The explanation is here.
    Stage (JavaFX 8) --setAlwaysOnTop

    I don't know what the explanation says, but what's clear is

    StageIs a method of

    The argument isbooleanIs

    I think it's easy to try if you know this, but what do you know?