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)); }
/** * 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); } }
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)); }