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

Indeterminate ProgressBar initially tree invisible does not animate until layoutChildren()

    XMLWordPrintable

Details

    • x86
    • other

    Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10586]

      A DESCRIPTION OF THE PROBLEM :
      If an indeterminate ProgressBar that is initially not tree visible becomes tree visible in a manner that does not call ProgressBarSkin.layoutChildren(...), then it fails to animate.

      Inspection of class ProgressBarSkin source code reveals that it only plays indeterminateTransition in its layoutChildren(...) call.
      It seems that ProgressBarSkin should listen for changes in tree visibility of the ProgressBar to play the animation, because that is the condition enclosing the play() call.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a TabPane with 2 tabs. Add an indeterminate ProgressBar on the second tab. Show a Scene containing the TabPane. Select the second tab.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The ProgressBar should animate.
      ACTUAL -
      The ProgressBar does not animate.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package materialcss;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ProgressBar;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.stage.Stage;

      /**
       * Demonstrates ProgressBar failure to animate after becoming tree visible
       * without ProgressBarSkin getting a layoutChildren() call.
       **/
      public class ProgressBarTest extends Application {

         @Override
         public void start( final Stage primaryStage ) throws Exception {
            final TabPane root = new TabPane();
            root.getTabs()
                .add( new Tab( "1" ) );
            final Tab progressTab = new Tab( "2" );
            root.getTabs()
                .add( progressTab );
            progressTab.setContent( new ProgressBar() );
            final Scene scene = new Scene( root );
            primaryStage.setScene( scene );
            primaryStage.show();
         }

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

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

      CUSTOMER SUBMITTED WORKAROUND :
      Ensure in an ad hoc manner that the ProgressBar is tree visible during its Skin's initial layoutChildren(...) call.
      Or, when you know by some ad hoc means that the ProgressBar has become tree visible, do something that causes its Skin to receive a layoutChildren(...) call. For example, call ProgressBar.setVisible(false) followed by ProgressBar.setVisible(true).

      Creating a good workaround is hampered by client code's prohibition from listening to tree visibility due to it being marked as a private API.

      Attachments

        Issue Links

          Activity

            People

              jgiles Jonathan Giles
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: