2015-11-05 38 views
-1

即使給出的路徑正確&圖像在場景構建器中顯示,但它在運行應用程序時出現錯誤。即使url正確,javafx錯誤

Executing C:\Users\433240\Documents\NetBeansProjects\UI\dist\run547088191\UI.jar using platform C:\Program Files (x86)\Java\jdk1.8.0_40\jre/bin/java 
Device "Intel(R) G41 Express Chipset" (\\.\DISPLAY1) initialization failed : 
WARNING: bad driver version detected, device disabled. Please update your driver to at least version 8.15.10.2302 
null/Images/home.png 
Exception in Application start method 
java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 


Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found 
    at javafx.scene.image.Image.validateUrl(Image.java:1091) 
    ... 23 more 
Exception running application ui.Main 
Java Result: 1 
+0

路徑 「空/圖片/ home.png」 不正確。在打印它的地方顯示代碼。 –

回答

0

我有同樣的問題

解決方案:

去的Java控制器類和編寫代碼

private Image image; 

@FXML 
ImageView imageview; // type your imageview fixid 

    private void setImage(String url) { 
    try { 
     image = new Image(url); 
     imageview.setImage(image); 
    } catch (Exception e) { 
     System.out.println(e); 
    } 

}