i have a JavaFX project with many packages. i wanted to create a folder with all my icons within. the icon path is: src/icon/test.png and my class, where i try to initialize my Image, is: src/project/menus/ressources/settings/SettingWindow.java. my problem is, that i am not able to get to the root folder, into the icon folder.
here is my source for the SettingWindow:
package project.menus.ressources.settings;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
public class SettingWindow{
@FXML private TextField nameTF;
@FXML private Button pinButton;
private Stage stage;
public void setStage(Stage stage) {
this.stage = stage;
/*-----------------Here where i try to initialize the Image -------------*/
Image icon = new Image("file: /icon/test.png", 25,25, false, false);
pinButton.setGraphic(new ImageView(icon));
}
/*-----------------------------------------------------------------------*/
public TextField getNameField() {
return this.nameTF;
}
}
"file: /icon/test.png" is not the only thing i tried. i found somewhere a solution to get the root directory with getRoot() but i couldnt use this method. I cant use the AbsolutPath to the folder, because its planed to use this software on different PC's