Using NotificationMole in GWT

I was looking for a component similar to the Android Toast notification for GWT (I Googled long enough and I know that there is Ext-GWT that has something similar, but I want to avoid external libraries). It seems that NotificationMole is the component I'm looking for, and that this component is available in GWT 2.1. However, when I try to show it in my application, it never appears. Has anyone used this component? Here is an example of how I use it:

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(); 
+7
source share
2 answers

NotificationMole must be attached to the DOM before it can be displayed:

 HasWidgets panel; // This can be any panel that accepts children. NotificationMole nm = new NotificatioMole(); panel.add(nm); // Setup the NotificationMole... nm.show(); 
+10
source
 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); } 
0
source

All Articles