GWT通知小部件?

时间:2011-05-17 19:06:40

标签: gwt gwt-widgets

你知道GET是否有任何通知小部件,就像这里的那个?

http://demo.vaadin.com/sampler#NotificationHumanized

1 个答案:

答案 0 :(得分:8)

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