我想使用javafx从目录(Jar文件外部)加载图像,即/Users/ossama/Projects/Pi/javafx/prayertime/backgroundBlue-Wallpaper.jpg
,但是没有加载图像。
我想因为下面的代码会从jar文件中获取图像
请帮助
images = new ArrayList<String>();
directory = new File("/Users/ossama/Projects/Pi/javafx/prayertime/background/");
File[] files = directory.listFiles();
for(File f : files) {images.add(f.getName());}
System.out.println(images);
int countImages = images.size();
int imageNumber = (int) (Math.random() * countImages);
rand_Image_Path = directory + images.get(imageNumber);
String image = JavaFXApplication4.class.getResource(rand_Image_Path).toExternalForm();
Mainpane.setStyle("-fx-background-image: url('" + image + "'); -fx-background-image-repeat: repeat; -fx-background-size: 1080 1920;-fx-background-position: bottom left;");