JoaoGalli
JoaoGalli

Reputation: 472

How to load FXML from another Jar?

I have a dependency Jar with some FXML files that I would like to use, how can I reference it?

URL location = getClass().getResource("?????????.fxml");
    fxmlLoader.setResources(ResourceBundle.getBundle("messages", Locale.getDefault()));
    fxmlLoader.setLocation(location);
    fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());

Upvotes: 0

Views: 1026

Answers (1)

Perco
Perco

Reputation: 160

Region root = FXMLLoader.load(getClass().getResource("FILE.fxml"));
final FILEJAVA filejava = new FILEJAVA(stage, root);

or

BorderPane pane = null;
        try {
            pane = (BorderPane) FXMLLoader.load(FILEJAVA.class.getResource("FILE.fxml"));
            pane.getStyleClass().add("main");
        } catch (IOException ex) {

            Logger.getLogger(FILEJAVA.class.getName()).log(Level.SEVERE, null, ex);
            System.exit(-1);
        }

Upvotes: 1

Related Questions