因在一个新的javafx项目中需要引入图片,打包后程序运行报错(打包可以参考之前文章):
后经查看,是图片没加载到。
解决办法:
1. 将需要的图片放入项目resource下,
2. 项目中引入图片:
private final ImageView icon = new ImageView(new Image(getClass().getResourceAsStream("/redline.jpg")));
重新打包后运行成功!
因在一个新的javafx项目中需要引入图片,打包后程序运行报错(打包可以参考之前文章):
后经查看,是图片没加载到。
解决办法:
1. 将需要的图片放入项目resource下,
2. 项目中引入图片:
private final ImageView icon = new ImageView(new Image(getClass().getResourceAsStream("/redline.jpg")));
重新打包后运行成功!