Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8230127

"stage.setAlwaysOnTop(true)" and "alert.showAndWait()" may cause app block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx13
    • javafx

      A DESCRIPTION OF THE PROBLEM :
      I met following scenario:
      1)Stage A is set as "setAlwaysOnTop(true)".
      2) Stage B pops an Alert to have user select some buttons.
      3) Stage A is on top and covering buttons of the Alert.
      Then app is blocking: Stage A can not get focus before user click buttons on Alert but Alert is unavaliable before stage A is moved away from top of it.

      This happens due to Alert's not bring itself to front. When it stays under others, problem happens.

      I found following solution:
      https://stackoverflow.com/questions/38799220/javafx-how-to-bring-dialog-alert-to-the-front-of-the-screen?r=SearchResults
      And solved this problem by adding following lines for all alerts in my app:
      Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
      stage.setAlwaysOnTop(true);
      stage.toFront();

      But I do not think this is the right way to avoid this problem. Maybe Alert need always bring itself to top automatically to avoid blocking whole application.



            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: