lundi 1 juin 2020

is there any way load FXML in package except deafult package in java [duplicate]

i am trying to load FXML loader in a specific package but i get java.lang.reflect.InvocationTargetException and java.lang.IllegalStateException: Location is not set. i dont know what to do i dont want to put my classes in default package due to some reason what should i do

here is my code and note the class main is in view package

private static Parent loadFXML(String fxml) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getClassLoader().getParent().getResource("view." + fxml + ".fxml"));
        return fxmlLoader.load();
    }





Aucun commentaire:

Enregistrer un commentaire