2012-03-08 74 views
0

我想將圖像添加到畫布上,然後計劃旋轉圖像。gwt圖形和gwt初學者 - 無法在屏幕上顯示光柵圖像

這是我使用的代碼---

  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); 

我已經保存在「戰爭/圖片/ bottle.jpg」的形象......但是當我嘗試運行正在顯示沒有圖像該項目作爲Google Web應用程序 - 我正在使用安裝了GWT和Google Plugins for Eclipse的Eclipse IDE。

我在這裏做錯了什麼?默認情況下存儲圖像的位置是否有所不同?任何幫助,將不勝感激。

回答

1

位置正確,但您可能需要更正圖像的路徑。爲此,請使用GWT.getHostPageBaseURL()

Image img= new Image(100, 100, 141, 538, GWT.getHostPageBaseURL() + "images/bottle.jpg");