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

Scene is black after stage is restored (content changed while minimized)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u66
    • javafx
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Scene is black after the stage is restored if there were changes in the scenegraph (nodes added) while the window was minimized.
      In order to reproduce the problem, the scene should contain controls that don't have a different look when focused, so as not to trigger any invalidation.
      Of course, if there are controls such as buttons, etc., which are painted differently when focused, the problem will be hidden.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. define a empty scene that uses the Modena CSS
      2. minimize the stage (either by clicking the Taskbar button, or by pressing the _ control button in the upper right corner of the window)
      3. make a change in the scenegraph (in the source code attached, this change is produced by automatically adding a new label at the moment the stage is minimized)
      4. restore the stage by clicking the corresponding Taskbar button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The new label should be visible.
      ACTUAL -
      The scene is black.
      The content appears correctly only after resizing the stage a few pixels in any direction.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package playground.code;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class RepaintIssueApplication extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {
              final VBox root = new VBox();

              primaryStage.iconifiedProperty().addListener((observable, oldValue, newValue) -> {
                  if (primaryStage.isIconified()) {
                      root.getChildren().add(new Label("Label"));
                  }
              });

              final Scene scene = new Scene(root, 400, 400);
              primaryStage.setScene(scene);
              primaryStage.setTitle("Repaint Issue Application");
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch();
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      One method is to change some aspects of the scene via CSS. Please take a look at the following code: a pseudoclass has been defined for the root style class; it is added/removed based on the state of the stage.


      *workaround.css*

      .root:iconified {
          -fx-background-color: transparent;
      }


      *RepaintIssueApplication.java*

      import javafx.application.Application;
      import javafx.css.PseudoClass;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class RepaintIssueApplication extends Application {
          private static final PseudoClass ICONIFIED_PSEUDO_CLASS = PseudoClass.getPseudoClass("iconified");

          @Override
          public void start(Stage primaryStage) throws Exception {
              final VBox root = new VBox();

              primaryStage.iconifiedProperty().addListener((observable, oldValue, newValue) -> {
                  final boolean iconified = primaryStage.isIconified();
                  if (iconified) {
                      root.getChildren().add(new Label("Label"));
                  }
                  root.pseudoClassStateChanged(ICONIFIED_PSEUDO_CLASS, iconified);
              });

              final Scene scene = new Scene(root, 400, 400);
              scene.getStylesheets().add("workaround.css");

              primaryStage.setScene(scene);
              primaryStage.setTitle("Repaint Issue Application");
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch();
          }
      }


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

              Created:
              Updated: