I am trying to add an image to the canvas, and later plan to rotate the image.
This is the code I am using---
RootPanel rootPanel = RootPanel.get();
DrawingArea canvas = new DrawingArea(800, 800);
Image img= new Image(100, 100, 141, 538, "images/bottle.jpg");
canvas.add(img);
RootPanel.get().add(canvas);
I have stored the image in "war/images/bottle.jpg"... But no image is being shown when I try to run the project as a Google Web Application- I am using Eclipse IDE with GWT and Google Plugins for Eclipse installed.
What am I doing wrong here? Is the location to store images different by default? Any help would be appreciated.
The location is correct, but you probably need to correct the path to the image. To do this prefix the path to your image with GWT.getHostPageBaseURL()
:
Image img= new Image(100, 100, 141, 538, GWT.getHostPageBaseURL() + "images/bottle.jpg");