我正在尝试学习JavaFX,并制作一个可以显示用户表视图中的用户图像的用户列表。这是我的代码:
@FXML private ImageView image;
@FXML
public void buttonSHow(actionEvent actionEvent) throws MalformedURLException,FileNotFoundException {
CList =TAbleview.getSelectionmodel().getSelectedItems();
System.out.println(CList.get(0).getPicture());
//URL url = new URL(CList.get(0).getPicture());
//FileInputStream input = new FileInputStream (CList.get(0).getPicture());
image.setImage(new Image(CList.get(0).getPicture()));
}
我要用此代码执行的操作是使用存储在用户列表中的绝对路径为ImageView
设置Image
图像。 fxml
具有此功能:
<ImageView fx:id = "image"/>
当我尝试运行它时,它显示了MalformedURLException: unknown protocol e
的错误。我试图将网址手动打入fxml
中以查看其是否手动加载,
<ImageView>
<image>
<Image url = "@E:\test.jpg"/>
</image>
</ImageView>
但是它仍然给我同样的错误。如果这是一个愚蠢的问题,我感到抱歉。我是自己编程和学习的新手