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

Hiding dialog and showing new one causes dialog to be frozen

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • jfx11, 8, jfx17, jfx18, jfx19
    • javafx

      ADDITIONAL SYSTEM INFORMATION :
      Microsoft Windows [Version 10.0.17134.1040]
      openjdk version "13" 2019-09-17
      OpenJDK Runtime Environment AdoptOpenJDK (build 13+33)
      OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13+33, mixed mode, sharing)
      JavaFX 17

      A DESCRIPTION OF THE PROBLEM :
      Exiting nested loop from first dialog (dialog hide) and starting new one (showAndWait) causes the new dialog and its UI to be frozen, not rendering properly. After resize the dialog renders, but still remains frozen.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start application provided as executable code.
      2. Press "Start modal" button.
      3. Press one of buttons in new dialog.
      4. Resize new dialog and click in textfields, try to type something.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1. Application with one button has shown.
      2. New dialog with 2 buttons appears.
      3. New dialog appears and has 2 textfields.
      4. Dialog is rendered properly and textfields are clickable, typed letters renders properly.
      ACTUAL -
      3. Sometimes dialog is just white box, but mostly does not render and becomes frozen.
      4. Dialog only renders after resizing.

      ---------- BEGIN SOURCE ----------

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ApplicationModalSampleApp2
      {

          public static void main( String[] args )
          {
              System.err.println( Runtime.version().toString() );
              Application.launch( MainFx.class, args );
          }

          public static class MainFx extends Application
          {

              @Override
              public void start( final Stage primaryStage ) throws Exception
              {
                  final var button = new Button( "Start modal" );
                  button.setOnAction( e -> showModal( primaryStage ) );
                  final var root = new BorderPane( button );
                  final Scene aScene = new Scene( root, 800, 600 );
                  primaryStage.setScene( aScene );
                  primaryStage.show();
              }

              private void showModal( final Stage mainStage )
              {
                  final var sampleModalStage = new Stage();
                  sampleModalStage.initOwner( mainStage );
                  final var closeMainStageButton = new Button( "Close main stage and show new dialog" );
                  closeMainStageButton.setOnAction( e -> closeMainStageAndOpenModalWithWait( mainStage ) );
                  final var closeModalButton = new Button( "Close modal stage and show new dialog" );
                  closeModalButton.setOnAction( e -> closeMainStageAndOpenModalWithWait( sampleModalStage ) );
                  sampleModalStage
                      .setScene( new Scene( new VBox( 5d, closeMainStageButton, closeModalButton ), 400, 400 ) );
                  sampleModalStage.showAndWait();
              }

              private void closeMainStageAndOpenModalWithWait( final Stage aStage )
              {
                  // this call exits secondary loop of first modal
                  aStage.hide();

                  final var sampleModalStage2 = new Stage();
                  sampleModalStage2.setScene(
                      new Scene( new VBox( 5d, new TextField( "sampleText" ), new TextField( "sampleText2" ) ), 400,
                          400 ) );
                  sampleModalStage2.setResizable( true );
                  // this call creates secondary loop of based on already exit secondary loop
                  sampleModalStage2.showAndWait();
              }

          }
      }


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      There's no workaround, except opening new modal in "Platform.runLater"

      FREQUENCY : always


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: