IntelliJ IDEA - getClass().getResource(“…”) return null

前端 未结 9 722
挽巷
挽巷 2020-12-15 16:21

I\'m using IntelliJ IDEA 13.1.5, I used to work with Eclipse. I\'m working on JavaFX application, I try to load FXML file within my MainApp class using getClass().getResourc

9条回答
  •  不知归路
    2020-12-15 16:58

    I gave up trying to use getClass().getResource("BookingForm.css"));

    Instead I create a File object, create a URL from that object and then pass it into getStyleSheets() or setLocation() File file = new File(System.getProperty("user.dir").toString() + "/src/main/resources/BookingForm.css");

    scene.getStylesheets().add(folder.toURI().toURL().toExternalForm());

提交回复
热议问题