我必須執行一個程序,它顯示位於java項目外的圖像。我不知道如何表達它們,我可以代表位於項目中的圖像,但不能代表它們。 這些是我在做什麼:在java項目中顯示位於java項目外的圖像
private String imagedir = "C://";
private String imageFileNames = "mypic.jpg";
ImageIcon icon;
icon = createImageIcon(imagedir + imageFileNames);
這給了我:Couldnt find file.
? – Braj
protected ImageIcon createImageIcon(String path,String description){0}如果(imgURL!= null){ }返回新的ImageIcon(imgURL,description); } else { System.err.println(「Could not find file:」+ path); return null; } – user3597131