我有一个依赖Jar,其中包含一些我想使用的FXML文件,我该如何引用它?
URL location = getClass().getResource("?????????.fxml");
fxmlLoader.setResources(ResourceBundle.getBundle("messages", Locale.getDefault()));
fxmlLoader.setLocation(location);
fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
答案 0 :(得分:1)
Region root = FXMLLoader.load(getClass().getResource("FILE.fxml"));
final FILEJAVA filejava = new FILEJAVA(stage, root);
或
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);
}