GWT通知小部件? [英] GWT notification widget?
本文介绍了GWT通知小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你知道GWT是否有任何通知部件,比如这里的一个?
http://demo.vaadin.com/sampler#NotificationHumanized
解决方案
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();
}
};
//安排定时器在3秒内关闭弹出窗口。
t.schedule(3000);
$ b 这不在我的脑中,所以它可能不会编译,但你明白了。
更新:
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(){
//编辑com.google.gwt.sample.contacts.client包
//与您自己的包名称匹配
tmp @ com.google.gwt.sample.contacts.client.Notification ::隐藏()();
$ wnd.onmousemove = null;
}
} - * /;
}
do you know if there is any notification widget for GWT out there, like this one here?
http://demo.vaadin.com/sampler#NotificationHumanized
解决方案 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;
}
}-*/;
}
这篇关于GWT通知小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文