迁移到JavaFX 8的问题

时间:2014-06-06 10:20:08

标签: java java-8 javafx-8 fxml

我最近安装了新的Java 8u5更新,因此我可以使用lambda操作和新的Scene Builder,但是我在加载FXML文档时遇到了问题。之前我在另一个线程中使用了FXMLLoader加载Platform.runLater(...)。但是这没有用,所以我把它放在JavaFX应用程序线程上,如下所示:

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字段前面吗?

1 个答案:

答案 0 :(得分:0)

看着

file:/C:/Users/Blah/path/to/my/Application.jar!/resources/GUI2.fxml

您需要使用7zip,WinZip或NetBeans打开Application.jar,并检查路径

/resources/GUI2.fxml

也许应该是

/GUI2.fxml

目录/resources很可能太多,源根目录是/src/main/resources左右。 (否则可能是区分大小写的问题。)