GWT notification widget?

▼魔方 西西 提交于 2019-12-05 01:18:29

问题


do you know if there is any notification widget for GWT out there, like this one here?

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


回答1:


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


来源:https://stackoverflow.com/questions/6035820/gwt-notification-widget

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!