Here are the steps to using ClientBundler
Step 1, add
Step 2. for the case of using Maven, copy/create images under src\main\resources
ex.
put two images logos.gif and quickResButton.gif under
src\main\resources\com\myapp\resources\images
Step 3. create your image bundle interface to extends ClientBundle
ex.
public interface MichaelImageBundle extends ClientBundle {
@Source("
public ImageResource mylogo();
@Source("
@ImageOptions(flipRtl = true)
public ImageResource mypointer();
public class Util {
private static MichaelImageBundle imgBundle = null;
public static MichaelImageBundle getInstance() {
if (
}
}
}
Step 4. create Image in your GWT code
ex.
MichaelImageBundle michaelImageBundle = MichaelImageBundle.Util.getInstance();
Image imgLogo = new Image(michaelImageBundle.mylogo().getURL());
Image imgMypointer = new Image(michaelImageBundle.mypointer().getURL());
That is.
For more information, refer to http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#ImageResource
Thanks for the information you provided! I managed to do it in a faster manner:
ReplyDelete1. add the image resource (file) to your java project, somewhere in the packages (I created a new package under client)
2. Right click somewhere in the project -> new -> Client Bundle -> fill in the name, browse for resources -> Finish
3. Address the resources. I went for a more direct approach rather than making a Singleton out of it.