相关疑难解决方法(0)

使用事件处理程序加载fxml文件的JavaFX 2.0失败

我正在尝试从子文件夹加载fxml,但它失败了.我有替换场景内容的行:

private Parent replaceSceneContent(String fxml) throws Exception {
        Parent page = (Parent) FXMLLoader.load(App.class.getResource("skinFolder/fxml/"+fxml), null, new JavaFXBuilderFactory());
        Scene scene = stage.getScene();
        if (scene == null) {
            scene = new Scene(page, 700, 450);
            scene.getStylesheets().add(App.class.getResource("skinFolder/css/defaultSkin.css").toExternalForm());
            stage.setScene(scene);
        } else {
            stage.getScene().setRoot(page);
        }
        stage.sizeToScene();
        return page;
    }
Run Code Online (Sandbox Code Playgroud)

我在下一个方法中使用此函数:

private void gotoLogin() {
        try {
            replaceSceneContent("login.fxml");
        } catch (Exception ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
Run Code Online (Sandbox Code Playgroud)

问题是我得到了下一个错误:

javafx.fxml.LoadException: Method processLogin() does not have the correct signature for an event handler.
    at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(Unknown Source)
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source) …
Run Code Online (Sandbox Code Playgroud)

java javafx-2 fxml

3
推荐指数
1
解决办法
8249
查看次数

标签 统计

fxml ×1

java ×1

javafx-2 ×1