1
我最近安装了新的Java 8u5更新,因此我可以使用lambda操作和新的Scene Builder,但是我立即遇到了加载FXML文档的问题。在我用不同的线程完成之前,使用Platform.runLater(...)加载使用FXMLLoader
。然而,这并没有工作,所以我把它放在JavaFX应用程序线程这样的:迁移到JavaFX 8的问题
ready.addListener((ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) -> {
if (Boolean.TRUE.equals(t1)) {
Platform.runLater(() -> {
try {
//skipped loading the other FXML documents for this post...
final FXMLLoader load = new FXMLLoader(guiResource);
final GUIController guiController = new GUIController();
load.setController(guiController);
scene = new Scene((AnchorPane) load.load());
stage.setScene(scene);
} catch (IOException ex) {
Util.err(ex.getLocalizedMessage());
}
stage.show();
});
}
}
但是我仍然在NetBeans控制台收到此而无益的帖子:
file:/C:/Users/Blah/path/to/my/Application.jar!/resources/GUI2.fxml
这是所有说。有没有其他人有这个问题?这是什么意思?为什么在.jar之后会出现感叹号?
我想这个问题可能有一些与我的变量声明在控制器所以这里有一个例子:
@FXML
Region fileImportVeil;
@FXML
ProgressIndicator fileImportProgressIndicator;
难道我的意思是把private
在我所有的FXML领域的面前?
您不需要在其前面放置“private”。如果你什么都不用(包私有),私有或受保护的变量,你需要'@ FXML'注释,为你不需要的公共变量。 '.jar!'意味着资源在* JAR里面。您需要提供更多的数据才能提供帮助,从异常的堆栈跟踪开始。 – skiwi
我不知道异常在哪里;所有它给我的是文件的路径,没有stacktrace,否则我会发布它! – Cobbles
你正在用'Util.err(ex.getLocalizedMessage())'吞吞stacktrace,因此你只会显示错误信息。 – skiwi