本文整理匯總了Java中javafx.animation.Timeline.setDelay方法的典型用法代碼示例。如果您正苦於以下問題:Java Timeline.setDelay方法的具體用法?Java Timeline.setDelay怎麽用?Java Timeline.setDelay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.animation.Timeline
的用法示例。
在下文中一共展示了Timeline.setDelay方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showPopup
import javafx.animation.Timeline; //導入方法依賴的package包/類
protected void showPopup() {
init();
isShowing = true;
VBox popupLayout = new VBox();
popupLayout.setSpacing(10);
popupLayout.setPadding(new Insets(10, 10, 10, 10));
StackPane popupContent = new StackPane();
popupContent.setPrefSize(width, height);
popupContent.getStyleClass().add("notification");
popupContent.getChildren().addAll(popupLayout);
popup = new Popup();
popup.setX(getX());
popup.setY(getY());
popup.getContent().add(popupContent);
popup.addEventHandler(MouseEvent.MOUSE_PRESSED, new WeakEventHandler<>(event -> {
fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.NOTIFICATION_PRESSED));
hidePopUp();
}));
popups.add(popup);
// Add a timeline for popup fade out
KeyValue fadeOutBegin = new KeyValue(popup.opacityProperty(), 1.0);
KeyValue fadeOutEnd = new KeyValue(popup.opacityProperty(), 0.0);
KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
KeyFrame kfEnd = new KeyFrame(popupAnimationTime, fadeOutEnd);
timeline = new Timeline(kfBegin, kfEnd);
timeline.setDelay(popupLifetime);
timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
hidePopUp();
}));
if (stage.isShowing()) {
stage.toFront();
} else {
stage.show();
}
popup.show(stage);
fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.SHOW_NOTIFICATION));
timeline.play();
}