2

我在 GWT 的主页上有一个按钮。单击此按钮时,屏幕将更新为新的 GWT 元素,并且无需发送 RPC 调用。但这两个屏幕之间,有很长的时间。所以我想为此制作一个加载指示器(如动画 gif)。

我该怎么做 ?

4

2 回答 2

10

GWT 类 PopupPanel 有一个可选的“玻璃面板”,它阻止与下方页面的交互。

final PopupPanel popup = new PopupPanel(false, true); // Create a modal dialog box that will not auto-hide
popup.add(new Label("Please wait"));
popup.setGlassEnabled(true); // Enable the glass panel
popup.center(); // Center the popup and make it visible
于 2013-07-24T13:28:20.677 回答
2

嗨,我已经实现了他。我在加载另一个屏幕之前附上了加载图像。下面是代码:

public class Utility {

private static LoadingDlg dlg=new LoadingDlg(false, true);

public static void showLoading(){
    if(count <= 0){


        dlg.center();
        count = 1;
    }
    else
    count++;

}
public static void hideLoading(){
    if(count <= 1){
        dlg.hide();     
        count = 0;
    }
    else{
    count--;
    }
}

}






public LoadingDlg(boolean autoHide, boolean modal) {
    super(autoHide, modal);
    this.setGlassEnabled(true);
    this.setTitle("Press Esc Key to Hide.");
    this.setGlassStyleName("loadingstyle");     
    FlowPanel hp=new FlowPanel();
    hp.setStyleName("loadingImg");
    this.getElement().getStyle().setZIndex(500);
    this.setWidget(hp);

}

相同的CSS:

.loadingstyle{
display: block !important;   
visibility: visible !important;    
z-index: 500 !important;
background-color: #000;
opacity: 0.3;
filter: alpha(opacity=30);

}

   .loadingImg{
background-image:url(images/loadingimage.gif);
background-repeat:no-repeat;
display: block; 
height: 24px;
width: 161px;

} 。

您必须在图像文件夹中添加 loadingimage.gif 并相应地调用 showLoading 和 hideLoading 函数。

于 2013-07-24T18:29:28.120 回答