do you know if there is any notification widget for GWT out there, like this one here?
Asked
Active
Viewed 4,447 times
1 Answers
9
AFAIK there is no such widget in core GWT, but why not roll your own:
public class DelayedPopup extends PopupPanel {
public DelayedPopup(String text, boolean autoHide, boolean modal) {
super(autoHide, modal);
setWidget(new Label(text));
}
void show(int delayMilliseconds) {
show();
Timer t = new Timer() {
@Override
public void run() {
DelayedPopup.this.hide();
}
};
// Schedule the timer to close the popup in 3 seconds.
t.schedule(3000);
}
}
This is out of my head so it might not compile, but you get the idea.
Update:
As per comment, I'm adding notification that hides itself on mouse move:
public class Notification extends PopupPanel {
public Notification(String text) {
super(false, false);
setWidget(new Label(text));
}
@Override
public void show() {
installCloseHandler();
super.show();
}
public native void installCloseHandler() /*-{
var tmp = this;
$wnd.onmousemove = function() {
// edit the com.google.gwt.sample.contacts.client package
// to match your own package name
tmp.@com.google.gwt.sample.contacts.client.Notification::hide()();
$wnd.onmousemove = null;
}
}-*/;
}

Peter Knego
- 79,991
- 11
- 123
- 154
-
I agree it should be easy to roll your own. It's worth noting that the one linked to above appears to not use a timer to dismiss the notification. Instead, it appears to listen for onMouseMove and immediately starts the dismissal when the mouse moves. – pohl May 17 '11 at 20:26
-
You are right. Updated post with a new version that hides notification on mouse move. – Peter Knego May 17 '11 at 21:04