public JFXSnackbar(Pane snackbarContainer) { initialize(); content = new StackPane(); content.getStyleClass().add("jfx-snackbar-content"); //wrap the content in a group so that the content is managed inside its own container //but the group is not managed in the snackbarContainer so it does not affect any layout calculations getChildren().add(content); setManaged(false); setVisible(false); // register the container before resizing it registerSnackbarContainer(snackbarContainer); // resize the popup if its layout has been changed layoutBoundsProperty().addListener((o, oldVal, newVal) -> refreshPopup()); addEventHandler(SnackbarEvent.SNACKBAR, e -> enqueue(e)); }
openAnimation.stop(); if (this.isVisible()) { Timeline closeAnimation = new Timeline( new KeyFrame( Duration.ZERO, e -> this.toFront(), new KeyValue(this.opacityProperty(), 1, easeInterpolator), new KeyValue(this.translateYProperty(), 0, easeInterpolator) ), new KeyFrame( Duration.millis(290), new KeyValue(this.visibleProperty(), true, Interpolator.EASE_BOTH) ), new KeyFrame(Duration.millis(300), e -> this.toBack(), new KeyValue(this.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(this.translateYProperty(), this.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(this.opacityProperty(), 0, easeInterpolator) resetPseudoClass(); processSnackbar(); }); closeAnimation.play();
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); }
private void refreshPopup() { Bounds contentBound = this.getLayoutBounds(); double offsetX = Math.ceil(snackbarContainer.getWidth() / 2) - Math.ceil(contentBound.getWidth() / 2); double offsetY = snackbarContainer.getHeight() - contentBound.getHeight(); this.setLayoutX(offsetX); this.setLayoutY(offsetY); }
new KeyFrame( Duration.ZERO, e -> this.toBack(), new KeyValue(this.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(this.translateYProperty(), this.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(this.opacityProperty(), 0, easeInterpolator) ), new KeyFrame( Duration.millis(10), e -> this.toFront(), new KeyValue(this.visibleProperty(), true, Interpolator.EASE_BOTH) ), new KeyFrame(Duration.millis(300), new KeyValue(this.opacityProperty(), 1, easeInterpolator), new KeyValue(this.translateYProperty(), 0, easeInterpolator) eventsSet.remove(currentEvent); currentEvent = eventQueue.peek(); close(); }); pauseTransition.play();
bindAction(burger4); snackbar = new JFXSnackbar(root); snackbar.setPrefWidth(300); snackbar.fireEvent(new SnackbarEvent(new JFXSnackbarLayout("Toast Message " + count))); } else { if (count % 4 == 0) { JFXButton button = new JFXButton("CLOSE"); button.setOnAction(action -> snackbar.close()); snackbar.fireEvent(new SnackbarEvent( new JFXSnackbarLayout("Snackbar Message Persistent " + count, "CLOSE", action -> snackbar.close()), Duration.INDEFINITE, null)); snackbar.fireEvent(new SnackbarEvent( new JFXSnackbarLayout("Snackbar Message" + count, "UNDO", null), Duration.millis(3000), null));
/** * Create a {@link JFXSnackbar}. * * @param snackBarContainer * the {@link Pane} container * @param message * the {@link String} message * @param secondsDuration * duration * @param textSize * the {@link DimDialogs} size * @param event * the {@link ActionEvent} */ public static void showSnackBar(final Pane snackBarContainer, final String message, final NotificationType.Duration secondsDuration, final DimDialogs textSize, final EventHandler<ActionEvent> event) { final JFXSnackbar bar = new JFXSnackbar(snackBarContainer); final SnackbarEvent eventToast = new SnackbarEvent(message, null, (long) secondsDuration.getValue() * 1000, false, event); bar.enqueue(eventToast); } }
private void show(SnackbarEvent event) { content.getChildren().setAll(event.getContent()); openAnimation = getTimeline(event.getTimeout()); if (event.getPseudoClass() != null) { activePseudoClass = event.getPseudoClass(); content.pseudoClassStateChanged(activePseudoClass, true); } openAnimation.play(); }
new KeyFrame( Duration.ZERO, e -> this.toBack(), new KeyValue(this.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(this.translateYProperty(), this.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(this.opacityProperty(), 0, easeInterpolator) ), new KeyFrame( Duration.millis(10), e -> this.toFront(), new KeyValue(this.visibleProperty(), true, Interpolator.EASE_BOTH) ), new KeyFrame(Duration.millis(300), new KeyValue(this.opacityProperty(), 1, easeInterpolator), new KeyValue(this.translateYProperty(), 0, easeInterpolator) eventsSet.remove(currentEvent); currentEvent = eventQueue.peek(); close(); }); pauseTransition.play();
private void refreshPopup() { Bounds contentBound = this.getLayoutBounds(); double offsetX = Math.ceil(snackbarContainer.getWidth() / 2) - Math.ceil(contentBound.getWidth() / 2); double offsetY = snackbarContainer.getHeight() - contentBound.getHeight(); this.setLayoutX(offsetX); this.setLayoutY(offsetY); }
private void show(SnackbarEvent event) { content.getChildren().setAll(event.getContent()); openAnimation = getTimeline(event.getTimeout()); if (event.getPseudoClass() != null) { activePseudoClass = event.getPseudoClass(); content.pseudoClassStateChanged(activePseudoClass, true); } openAnimation.play(); }
public JFXSnackbar(Pane snackbarContainer) { initialize(); content = new StackPane(); content.getStyleClass().add("jfx-snackbar-content"); //wrap the content in a group so that the content is managed inside its own container //but the group is not managed in the snackbarContainer so it does not affect any layout calculations getChildren().add(content); setManaged(false); setVisible(false); // register the container before resizing it registerSnackbarContainer(snackbarContainer); // resize the popup if its layout has been changed layoutBoundsProperty().addListener((o, oldVal, newVal) -> refreshPopup()); addEventHandler(SnackbarEvent.SNACKBAR, e -> enqueue(e)); }
openAnimation.stop(); if (this.isVisible()) { Timeline closeAnimation = new Timeline( new KeyFrame( Duration.ZERO, e -> this.toFront(), new KeyValue(this.opacityProperty(), 1, easeInterpolator), new KeyValue(this.translateYProperty(), 0, easeInterpolator) ), new KeyFrame( Duration.millis(290), new KeyValue(this.visibleProperty(), true, Interpolator.EASE_BOTH) ), new KeyFrame(Duration.millis(300), e -> this.toBack(), new KeyValue(this.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(this.translateYProperty(), this.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(this.opacityProperty(), 0, easeInterpolator) resetPseudoClass(); processSnackbar(); }); closeAnimation.play();
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); }