Stuck in the basics. I have some syntax issues setting up the Image Path. When i try to create an Image and give it the image path, it always throws some some exception about the path. I have commented out some of the path combination I have already tryed. Can you please tell me what I am doing wrong? Thank you.
package jopofx;
public JoPoCTRL(JoPoFX gui){
this.gui = gui;
}
public void updateImages(){
Image img = null;
try{
//img = new Image("C:\\Users\\ ... //FullPath ... \\JoPoFX\\src\\jopofx\\myimage.png");
img = new Image("\\JoPoFX\\src\\jopofx\\myimage.png");
//img = new Image("\\src\\jopofx\\myimage.png");
//img = new Image("\\myimage.png");
}catch(Exception e){
System.out.println("error while creating image");
e.printStackTrace();
}
try{
gui.setImgV(img);
}catch(Exception e){
System.out.println("error while setting up the image");
}
}
This is what prints out: error while creating image java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found at javafx.scene.image.Image.validateUrl(Image.java:990) at javafx.scene.image.Image.(Image.java:538)
Aucun commentaire:
Enregistrer un commentaire