2011-02-08 14 views
7

Estaba buscando un componente similar a la notificación Toast de Android para GWT (busqué en Google el tiempo suficiente y sé que existe un Ext-GWT que tiene algo similar, pero quiero evitar las bibliotecas externas). Parece que NotificationMole es el componente que estoy buscando, y que este componente está disponible en GWT 2.1. Sin embargo, cuando intento mostrarlo en mi aplicación, nunca aparece. ¿Alguien ha usado este componente? Aquí hay un ejemplo de cómo lo uso:Uso de NotificationMole en GWT

NotificationMole nm = new NotificationMole(); 
nm.setAnimationDuration(2000); 
nm.setTitle("Title"); 
nm.setHeight("100px"); 
nm.setWidth("200px"); 
nm.setMessage("Test message to be shown in mole"); 
nm.show(); 

Respuesta

10

El NotificationMole tiene que ser conectado a la DOM antes de que se pueda demostrar:

HasWidgets panel; // This can be any panel that accepts children. 
NotificationMole nm = new NotificatioMole(); 
panel.add(nm); 
// Setup the NotificationMole... 
nm.show(); 
+0

Gracias, esta era la solución de mi problema . – dstefanox

0
private void tellUser(String what) 
{ 
    PopupPanel pop = new PopupPanel(true); 
    pop.setWidget(new Label(what)); 


    final PopupPanel p = pop; 

    RootPanel.get().add(pop); 

    pop.setPopupPositionAndShow(new PopupPanel.PositionCallback() { 
      public void setPosition(int offsetWidth, int offsetHeight) { 
      int left = (Window.getClientWidth() - offsetWidth)/2; 
      int top = (Window.getClientHeight() - offsetHeight)/2; 
      p.setPopupPosition(left, top); 
      } 
     }); 

    new Timer() { 
     @Override 
     public void run() 
     { 
     System.out.println("timer repeated"); 
     RootPanel.get().remove(p); 
     this.cancel(); 
     } 
    }.scheduleRepeating(2000); 
}