Default Delays
First of all, note that the five types Notification have different delays by default.
Notification.Type.HUMANIZED_MESSAGE
It is displayed until the user moves the mouse pointer.Notification.Type.TRAY_NOTIFICATION
It is displayed up to 3 seconds after the user moves the mouse cursor.Notification.Type.WARNING_MESSAGE
It is displayed up to 1.5 seconds after the user moves the mouse cursor.Notification.Type.ERROR_MESSAGE
, . ( )Notification.Type.ASSISTIVE_NOTIFICATION
Safari Mac OS X Mountain Lion.
. , .
Notification : getDelayMsec setDelayMsec.
, , .
notification.setDelayMsec( 7 * 1_000 );
"" TimeUnit. long, int Vaadin.
notification.setDelayMsec( ( int ) TimeUnit.SECONDS.toMillis( 7 ) );
. ERROR_MESSAGE, ""; .
. , .
Vaadin 7.5.3. Vaadin. Vaadin .
/ Vaadin. ( JRebel, .)

package com.example.vaadinnotifs;
import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import java.util.concurrent.TimeUnit;
@Theme ( "mytheme" )
@Widgetset ( "com.example.vaadinnotifs.MyAppWidgetset" )
@SuppressWarnings ( "serial" )
public class MyUI extends UI
{
@Override
protected void init ( VaadinRequest vaadinRequest ) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin( true );
layout.setSpacing( true );
setContent( layout );
layout.addComponent( this.makeButton( Notification.Type.HUMANIZED_MESSAGE ) );
layout.addComponent( this.makeButton( Notification.Type.TRAY_NOTIFICATION ) );
layout.addComponent( this.makeButton( Notification.Type.WARNING_MESSAGE ) );
layout.addComponent( this.makeButton( Notification.Type.ERROR_MESSAGE ) );
layout.addComponent( this.makeButton( Notification.Type.ASSISTIVE_NOTIFICATION ) );
}
@WebServlet ( urlPatterns = "/*" , name = "MyUIServlet" , asyncSupported = true )
@VaadinServletConfiguration ( ui = MyUI.class , productionMode = false )
public static class MyUIServlet extends VaadinServlet
{
}
private Button makeButton ( Notification.Type typeArg ) {
Button b = new Button( typeArg.name() );
b.setData( typeArg );
b.addClickListener( new Button.ClickListener()
{
@Override
public void buttonClick ( ClickEvent event ) {
Notification.Type t = ( Notification.Type ) event.getButton().getData();
Notification notification = new Notification( "This is a Notification message." , t );
Integer delayMillis = notification.getDelayMsec();
String description = "Notification.Type: " + t.name() + " has delay of " + delayMillis + " ms.";
notification.setDescription( description );
notification.show( Page.getCurrent() );
}
} );
return b;
}
}