/** * <p> * Description copied from corresponding location in WebComponent: * </p> * <p> * The duration in milliseconds to show the notification. Set to {@code 0} * or a negative number to disable the notification auto-closing. * </p> * * @param duration * the value to set */ public void setDuration(int duration) { setDuration((double) duration); }
/** * Creates a Notification with given text String, duration and position * <P> * Set to {@code 0} or a negative number to disable the notification * auto-closing. * * @param text * the text of the notification * @param duration * the duration in milliseconds to show the notification * @param position * the position of the notification. Valid enumerate values are * TOP_STRETCH, TOP_START, TOP_CENTER, TOP_END, MIDDLE, * BOTTOM_START, BOTTOM_CENTER, BOTTOM_END, BOTTOM_STRETCH */ public Notification(String text, int duration, Position position) { initBaseElementsAndListeners(); setText(text); setDuration((double) duration); setPosition(position); }
@Override public void onNotificationAdded(Notification notification) { if (!isOpened()) { NotificationViewWithoutWrapper view = new NotificationViewWithoutWrapper(notification, holder); view.setWidth("200px"); com.vaadin.flow.component.notification.Notification notificationView = new com.vaadin.flow.component.notification.Notification(view); notificationView.setPosition(com.vaadin.flow.component.notification.Notification.Position.TOP_END); notificationView.setDuration(2000); notificationView.open(); } }
/** * Default constructor. Create an empty notification with component support * and non-auto-closing * <p> * Note: To mix text and child components in notification that also supports * child components, use the {@link Text} component for the textual parts. */ public Notification() { initBaseElementsAndListeners(); getElement().getNode().runWhenAttached(ui -> ui .beforeClientResponse(this, context -> deferredJob.accept(ui))); setPosition(DEFAULT_POSITION); setDuration(0); }