确保在浏览器上显示图像

时间:2011-10-02 09:11:59

标签: gwt gwt2

如何确保在进一步操作之前在浏览器上显示图像?

我想按特定顺序加载一些图像,因为我想确保图像始终作为背景。我写了以下代码:

// load the view
final IView bgView = new StaticImgView(Constants.BG_CLASS, "Background", bgPath);
this.dPanel.add(bgView);
bgView.addErrorHandler(new ErrorHandler() {

    @Override
    public void onError(ErrorEvent event) {

        GWT.log("No Background-View.");
        loadLogoView();

    }

});
bgView.addLoadHandler(new LoadHandler() {

    @Override
    public void onLoad(LoadEvent event) {

        GWT.log("Background-View loaded.");
        GWT.log("> " + TicketViewer.this.dPanel.getWidgetCount());
        loadLogoView();

    }

});

但'Logo'图像不会显示在背景上..(?)。

  • bgView扩展了图像。

  • loadLogoView包含加载其他图像的类似代码。

  • 请注意,背景图片为800x600,而所有其他图片均为104x100。

2 个答案:

答案 0 :(得分:0)

这取决于进一步行动的内容。一般情况是如果您使用的是JQuery,则可以执行以下操作:

$('#imageId').load(function() { //Do Something })

其中imageId对应于img标记中的ID。

<img src="test.jpg" id="imageId" />

答案 1 :(得分:0)

为图片添加LoadHandlerImage.addLoadHandler(LoadHandler))。

相关问题