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

Problems animating pane in Popup

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • javafx
    • Mac OS X 10.8.3 jdk8b91

    Description

      I'm trying to animate a popup window. The animation on the opacity works OK but trying to animate the scaleX or scaleY property does strange things. Try the enclosed program and press the 'Show Popup' button. Nothing appears but some graphical garbage. Strangely, changing the keyframe times to 3000 and 6000 milliseconds (instead of 300 and 600) makes it work OK, albeit taking longer. This used to work in earlier versions of jdk8.

      import javafx.animation.KeyFrame;
      import javafx.animation.KeyValue;
      import javafx.animation.Timeline;
      import javafx.application.Application;
      import javafx.geometry.Bounds;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.Pane;
      import javafx.stage.Popup;
      import javafx.stage.Stage;
      import javafx.stage.Window;
      import javafx.util.Duration;

      public class PopupBug extends Application {
      public static void main(String[] args) {
      Application.launch(args);
      }

      public void start(Stage stage) throws Exception {
      Label l = new Label("I'm a popup!");
      l.setStyle("-fx-font-size: 3em; -fx-text-fill: white;");
      BorderPane p = new BorderPane(l);
      p.setStyle("-fx-padding:20; -fx-border-style: solid; -fx-border-width: 2; -fx-border-color: blue; -fx-background-color: black;");

      Button b = new Button("Show Popup");
      b.setOnAction((e) -> showPopup(b, p));
      BorderPane bp = new BorderPane(b);
      Scene scene = new Scene(bp, 800, 600);
      stage.setScene(scene);
      stage.show();
      }

      public void showPopup(Node refNode, Pane pane) {
      Scene scene = refNode.getScene();
      Window parent = scene.getWindow();
      if (parent != null) {
      Bounds sb = refNode.localToScene(refNode.getLayoutBounds());
      Popup pop = new Popup();
      pop.setAutoHide(true);
      pop.setAutoFix(true);
      pop.setHideOnEscape(true);
      pop.getContent().add(pane);
      pop.show(refNode, sb.getMinX() + parent.getX() + scene.getX(), sb.getMaxY() + parent.getY() + scene.getY());
      Node an = pane;
      new Timeline(
      new KeyFrame(Duration.millis(0),
      new KeyValue(an.scaleXProperty(), 0.2),
      new KeyValue(an.scaleYProperty(), 0.2)
      ),
      new KeyFrame(Duration.millis(300),
      new KeyValue(an.scaleXProperty(), 1.1),
      new KeyValue(an.scaleYProperty(), 1.1)
      ),
      new KeyFrame(Duration.millis(600),
      new KeyValue(an.scaleXProperty(), 1.0),
      new KeyValue(an.scaleYProperty(), 1.0)
      )
      ).play();
      }
      }
      }

      Attachments

        Issue Links

          Activity

            People

              psafrata Pavel Ĺ afrata
              cstanford Curtis Stanford
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: