2011-02-08 6 views
7

私はGWTのAndroidのToast通知に似たコンポーネントを探していました(私はかなり長くGoogleで検索しましたが、Ext-GWTには同様の機能がありますが、外部ライブラリは避けたい)。 NotificationMoleは、私が探しているコンポーネントであり、このコンポーネントはGWT 2.1で利用可能です。しかし、私は私のアプリでそれを表示しようとすると、決して表示されません。誰もこのコンポーネントを使用しましたか?ここで私はそれを使用する方法の例です:GWTでNotificationMoleを使用

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(); 

答えて

10

NotificationMoleは、それが示すことができる前に、DOMに添付する必要があります。

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

ありがとうございました、これは私の問題の解決策でした。 – 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); 
} 
関連する問題