GWT通知小部件?

GWT通知小部件?,gwt,gwt-widgets,Gwt,Gwt Widgets,你知道有没有GWT的通知小部件,比如这里的这个吗 AFAIK在核心GWT中没有这样的小部件,但是为什么不推出自己的小部件呢: public class DelayedPopup extends PopupPanel { public DelayedPopup(String text, boolean autoHide, boolean modal) { super(autoHide, modal); setWidget(new Label(text));

你知道有没有GWT的通知小部件,比如这里的这个吗


AFAIK在核心GWT中没有这样的小部件,但是为什么不推出自己的小部件呢:

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);
    }
}
这是我脑子里想不出来的,所以可能无法编译,但你明白了

更新:

根据评论,我添加了在鼠标移动时隐藏自己的通知:

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;
        }
    }-*/;
}

我同意这应该是很容易推出自己的。值得注意的是,上面链接的那个似乎没有使用计时器来取消通知。相反,它似乎在监听onMouseMove,并在鼠标移动时立即开始解雇。你是对的。更新了post,新版本隐藏了鼠标移动时的通知。