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

Drop shadow effect does not properly update with Timeline animations on child nodes

XMLWordPrintable

      Set up a VBox that contains an animated Rectangle. Add a drop shadow effect to the VBox. Then the drop shadow does not update correctly. See attached image for this problem.

      Here is the source code, which is also attached:



      import javafx.animation.KeyFrame;
      import javafx.animation.KeyValue;
      import javafx.animation.Timeline;
      import javafx.application.Application;
      import javafx.builders.*;
      import javafx.scene.effect.DropShadow;
      import javafx.scene.layout.AnchorPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;
      import javafx.util.Duration;


      public class DropShadowBugTest extends Application {

          @Override
          public void start(Stage stage) throws Exception {
              Rectangle toAnimate;

              //It is necessary to enclose the animated rectangle with
              //a VBox that has the effect, to see the bug.
              VBox vBox = new VBoxBuilder()
                      .children(
                              toAnimate = new RectangleBuilder()
                              .width(200)
                              .height(50)
                              .fill(Color.BLUE)
                              .stroke(Color.BLACK)
                              .build()
                      )
                      .effect(new DropShadow())
                      .build();

              //setup an AnchorPane to contain this VBox
              AnchorPane anchorPane = new AnchorPaneBuilder().children(vBox).build();
              AnchorPane.setLeftAnchor(vBox, 10.0);
              AnchorPane.setTopAnchor(vBox, 10.0);

              
              stage.setScene(new SceneBuilder().root(anchorPane).height(300).width(240).build());
              stage.setVisible(true);

              Timeline timeline = new TimelineBuilder()
                      .keyFrames(
                              new KeyFrame(Duration.valueOf(0), new KeyValue(toAnimate.heightProperty(), 50)),
                              new KeyFrame(Duration.valueOf(600), new KeyValue(toAnimate.heightProperty(), 200))
                      ).build();
              timeline.setAutoReverse(true);
              timeline.setCycleCount(-1);
              timeline.play();


          }

          public static void main(String[] args) {
              Application.launch(DropShadowBugTest.class, null);
          }


      }

            msladecek Martin Sládeček
            jforskyjfx Javic Forsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: