Timeline fiveSecondsWonder = new Timeline(new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("this is called every 5 seconds on UI thread"); } })); fiveSecondsWonder.setCycleCount(Timeline.INDEFINITE); fiveSecondsWonder.play();
@Override public <U> void setViewContext(ViewContext<U> context) { updatePlaceholder(context.getRootNode()); if (animation != null) { animation.stop(); } animation = new Timeline(); animation.getKeyFrames().addAll(animationProducer.apply(this)); animation.getKeyFrames().add(new KeyFrame(duration, (e) -> clearPlaceholder())); animation.play(); }
DoubleProperty y = new SimpleDoubleProperty(); Timeline timeline = new Timeline( new KeyFrame(Duration.seconds(0), new KeyValue(x, 0), timeline.setCycleCount(Timeline.INDEFINITE); stage.setScene( new Scene( new Group( stage.show(); timeline.play();
stage.setScene(new Scene(layout)); stage.show(); @Override public void handle(ActionEvent actionEvent) { Timeline flash = new Timeline( new KeyFrame(Duration.seconds(0), new KeyValue(warningColor, Color.GRAY, Interpolator.LINEAR)), new KeyFrame(Duration.seconds(0.25), new KeyValue(warningColor, Color.GRAY, Interpolator.LINEAR)),
private void createSlideshow(Stage stage, ArrayList<BufferedImage> slideList, int durationInSecs) throws InterruptedException { stage.show(); Timeline slideshow = new Timeline(); ImageView slide = new ImageView(); for (int i = 0; i < slideList.size(); i++) { BufferedImage bi = slideList.get(i); KeyFrame newImageFrame = new KeyFrame(Duration.seconds(durationInSeconds * 3 * i), e -> slide.setImage(SwingFXUtils.toFXImage(bi, null))); KeyFrame startFadeIn = new KeyFrame(Duration.seconds(durationInSeconds * 3 * i), new KeyValue(slide.opacityProperty(), 0)); KeyFrame endFadeIn = new KeyFrame(Duration.seconds(durationsInSeconds * (3 * i + 1)), new KeyValue(slide.opacityProperty(), 1)); KeyFrame startFadeOut = new KeyFrame(Duration.seconds(durationInSeconds * (3 * i + 2)), new KeyValue(slide.opacityProperty(), 1)); slideshow.getKeyFrames().addAll(newImageFrame, startFadeIn, endFadeIn, startFadeOut); } slideshow.play(); }
timeline.getKeyFrames().clear(); timeline = new Timeline(blueFrame[0], blueFrame[1], blueFrame[2], greenFrame[3], endingFrame); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setDelay(Duration.ZERO); timeline.playFromStart();
PseudoClass flashHighlight = PseudoClass.getPseudoClass("flash-highlight"); Node flashingNode = ... ; Timeline flasher = new Timeline( new KeyFrame(Duration.seconds(0.5), e -> { flashingNode.pseudoClassStateChanged(flashHighlight, true); }), new KeyFrame(Duration.seconds(1.0), e -> { flashingNode.pseudoClassStateChanged(flashHighlight, false); }) ); flasher.setCycleCount(Animation.INDEFINITE);
public void show() { dialog.setOpacity(0); // pickerDecorator.setOpacity(0); if (dialog.getOwner() != null) { dialog.widthProperty().addListener(positionAdjuster); dialog.heightProperty().addListener(positionAdjuster); positionAdjuster.invalidated(null); } if (dialog.getScene() == null) { dialog.setScene(customScene); } curvedColorPicker.preAnimate(); dialog.show(); if (initOnce) { initRun.run(); initOnce = false; } Timeline timeline = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(dialog.opacityProperty(), 1, Interpolator.EASE_BOTH))); timeline.setOnFinished((finish) -> curvedColorPicker.animate()); timeline.play(); }
public void moveCircle(Circle circle, Scene scene) { Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> { circle.setCenterX(random((int) scene.getX())); circle.setCenterY(random((int) scene.getY())); })); timeline.setCycleCount(Animation.INDEFINITE); timeline.play(); }
public class Main extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { IntegerProperty letters= new SimpleIntegerProperty(0); Label label = new Label(); Button animate = new Button("animate"); letters.addListener((a, b, c) -> { label.setText("animate".substring(0, c.intValue())); }); animate.setOnAction((e)->{ Timeline timeline = new Timeline(); KeyValue kv = new KeyValue(letters, "animate".length()); KeyFrame kf = new KeyFrame(Duration.seconds(3), kv); timeline.getKeyFrames().add(kf); timeline.play(); }); BorderPane pane = new BorderPane(label, null, null, animate, null); primaryStage.setScene(new Scene(pane, 300,300)); primaryStage.show(); } }
private void hideError() { if (heightChanged) { new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(translateYProperty(), 0, Interpolator.EASE_BOTH))).play(); // reset the height of text field new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(minHeightProperty(), initHeight, Interpolator.EASE_BOTH))).play(); heightChanged = false; } // clear error label text errorLabel.setText(null); oldErrorLabelHeight = errorLabelInitHeight; // clear error icon errorIcon.getChildren().clear(); // reset the height of the text field currentFieldHeight = initHeight; // hide error container errorContainer.setVisible(false); errorShown = false; }
public void show(boolean autohide) { if(canShow) { _prepareShow(autohide); dialogStage.getScene().getRoot().opacityProperty().set(0); dialogStage.show(); Timeline timeline = new Timeline(); KeyFrame key = new KeyFrame(Duration.millis(100), new KeyValue (dialogStage.getScene().getRoot().opacityProperty(), 1)); timeline.getKeyFrames().add(key); timeline.play(); canShow = false; } }
private FxTimer(java.time.Duration timeout, Runnable action, int cycles) { this.timeout = Duration.millis(timeout.toMillis()); this.timeline = new Timeline(); this.action = action; timeline.setCycleCount(cycles); }
jfxBarInf.setProgress(-1.0f); Timeline timeline = new Timeline( new KeyFrame( Duration.ZERO, new KeyValue(jfxBar.progressProperty(), 1))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.play(); scene.getStylesheets().add(ProgressBarDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); stage.setTitle("JFX ProgressBar Demo "); stage.setScene(scene); stage.setResizable(false); stage.show();
final double[] derivatives = new double[frictions.length]; Timeline timeline = new Timeline(); final EventHandler<MouseEvent> dragHandler = event -> timeline.stop(); final EventHandler<ScrollEvent> scrollHandler = event -> { timeline.play(); timeline.setCycleCount(Animation.INDEFINITE);
public class StageFadeExample extends Application { @Override public void start(Stage arg0) throws Exception { Stage stage = new Stage(); stage.initStyle(StageStyle.TRANSPARENT); //Removes window decorations Button close = new Button("Fade away"); close.setOnAction((actionEvent) -> { Timeline timeline = new Timeline(); KeyFrame key = new KeyFrame(Duration.millis(2000), new KeyValue (stage.getScene().getRoot().opacityProperty(), 0)); timeline.getKeyFrames().add(key); timeline.setOnFinished((ae) -> System.exit(1)); timeline.play(); }); Scene scene = new Scene(close, 300, 300); scene.setFill(Color.TRANSPARENT); //Makes scene background transparent stage.setScene(scene); stage.show(); } public static void main (String[] args) { launch(); } }
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2500)), new KeyFrame(Duration.millis(0), new KeyValue(node.scaleXProperty(), 1, EASE_BOTH), new KeyValue(node.scaleYProperty(), 1, EASE_BOTH), new KeyValue(node.scaleYProperty(), 1, EASE_BOTH), new KeyValue(node.rotateProperty(), 0, EASE_BOTH))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setDelay(Duration.millis(2000)); return timeline;
final ProgressBar bar = new ProgressBar(); final Timeline timeline = new Timeline( new KeyFrame(Duration.millis(0), new KeyValue(bar.progressProperty(), 0)), new KeyFrame(Duration.millis(3000), new KeyValue(bar.progressProperty(), 1)) layout.getChildren().setAll(bar, reset); layout.getStylesheets().add(getClass().getResource("progress.css").toExternalForm()); stage.setScene(new Scene(layout)); stage.show(); timeline.play();
@PostConstruct public void init() { Timeline timeline = new Timeline( new KeyFrame( Duration.ZERO, new KeyValue(blueSpinner.progressProperty(), 0), new KeyValue(greenSpinner.progressProperty(), 0) ), new KeyFrame( Duration.seconds(0.5), new KeyValue(greenSpinner.progressProperty(), 0.5) ), new KeyFrame( Duration.seconds(2), new KeyValue(blueSpinner.progressProperty(), 1), new KeyValue(greenSpinner.progressProperty(), 1) ) ); timeline.setCycleCount(Timeline.INDEFINITE); timeline.play(); }