5

ここにあるようなGWTの通知ウィジェットがあるかどうか知っていますか?

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

4

1 に答える 1

9

コア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;
        }
    }-*/;
}
于 2011-05-17T20:14:26.313 に答える