0
votes
public ImageBundleExample() {

    MyImageBundle objBundle = GWT.create(MyImageBundle.class);

    Image logo = new Image(objBundle.closeImageSource());

    HorizontalPanel objHorizontalPanel = new HorizontalPanel();
    objHorizontalPanel.add(logo);

    initWidget(objHorizontalPanel);
}

public interface MyImageBundle extends ClientBundle
{

    @Source("com/example/client/GUI/Images/close.jpg")
    public ImageResource closeImageSource();

    @Source("com/example/client/GUI/Images/closeLessPixels.jpg")
    public ImageResource closeLessPixelsImageSource();
}

Can you tell me how it optimize the performance ? What is difference in using direct Image or ClientBundle with ImageResorce. ?

1

1 Answers

2
votes

Using ClientBundle GWT will create one sprite of all the referenced images. Instead of calling n times the server (for each image) there is only one call.

You need the ImageResource to get the right image from the sprite.