在图像路径JavaFX中放置一个变量

时间:2018-04-04 02:21:21

标签: javafx

我是javaFX的初学者并且对imageview有疑问,我想在路径中生成一个带有变量的图像,就像它在swing上工作但不在javaFx上这里是代码和错误:

@Override
public void initialize(URL url, ResourceBundle rb) {

    com1.getItems().addAll("Francais","anglais","JEE","SOA","Math");
    com2.getItems().addAll("LFI1","LFI2","LFM2","PREPA","LFI3");

}    
void onShow(ActionEvent event) {

   String seance = com1.getSelectionModel().getSelectedItem(); //ComboBox with Strings
    Image qr= new Image("Qrimages/"+seance+".jpg"); 
    image.setImage(qr);

}

它说:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found

我尝试使用现有名称更改变量并且它可以工作,但我需要将此路径形式静态化为动态

0 个答案:

没有答案
相关问题