PDA

View Full Version : How do I add images to my GXT project



thomhehl
21 May 2012, 9:24 AM
I've found some stuff here and there, but none of it seems to be working properly. It appears that I should be creating an interface that extends ClientBundle, but it simply doesn't show up when I add the ImageBundle.

Can someone help me with this, please?

aechannaveen
22 May 2012, 1:25 AM
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;

public interface Icons extends ClientBundle
{
Icons INSTANCE = GWT.create(Icons.class);

@Source("resources/sampleImage.png")
ImageResource getMySampleImage();
}


From your class, use the Icons Interface as follows:


ContentPanel cp = new ContentPanel();
final Image mySampleImage = new Image(Icons.INSTANCE.getMySampleImage());
cp.add(mySampleImage)


Hope this helps you... ;)