Forum Stats

  • 3,854,516 Users
  • 2,264,375 Discussions
  • 7,905,714 Comments

Discussions

JavaFX Application is not AlwaysOnTop of all Win-Windows

Härry
Härry Member Posts: 16
edited Sep 12, 2016 6:47PM in JavaFX 2.0 and Later

Hy There,

i got a primaryStage where i set the following things for AlwaysOnTop Stuff:

primaryStage.toFront();

            primaryStage.setAlwaysOnTop(true);

I come up with a LoginDialog which is Windows.Modal

When i  open up a Windows Explorer, it slides between the LoginDialog (which is on Top)

and my primaryStage Window (which should be alwaysOnTop)

How can i prevent other win Apps to slide between or in Front of my Application window ?

Thanks and best regards,

Harry

Answers

  • bekwam
    bekwam Member Posts: 6
    edited Sep 12, 2016 5:34PM

    Hi,

    I've used this feature on a small utility window that was a secondary Stage, but haven't on the primaryStage yet.  This following program is working for me on Ubuntu.  I'm not sure why I can't make the setAlwaysOnTop() call from within primaryStage.setOnShown().

    -Carl

    public class zt extends Application {

        @Override

        public void start(Stage primaryStage) throws Exception {

            Button b = new Button("Dialog");

            b.setOnAction( (evt) -> showDialog(primaryStage) );

            VBox vbox = new VBox();

            vbox.getChildren().add( b );

            Scene scene = new Scene( vbox );

            primaryStage.setScene( scene );

            primaryStage.setWidth( 1024 );

            primaryStage.setHeight( 768 );

            primaryStage.show();

        }

        public static void main(String[] args) {

            launch(args);

        }

        private void showDialog(Stage primaryStage) {

            Label label = new Label("Dialog");

            VBox vbox = new VBox();

            vbox.getChildren().add( label );

            Scene scene = new Scene( vbox );

            Stage stage = new Stage();

            stage.setScene( scene );

            stage.setWidth( 667 );

            stage.setHeight( 375 );

            primaryStage.setAlwaysOnTop(true);

            stage.setAlwaysOnTop(true);

            stage.show();

        }

    }

  • bekwam
    bekwam Member Posts: 6
    edited Sep 12, 2016 6:47PM

    I tested this on Window 10 non tablet mode and Mac.

This discussion has been closed.