Java FXMLLoader.load无法解析为类型
因此,我使用JavaFX的Scene Builder工具创建了一个FXML接口,并试图通过我的代码加载它。但是,我在尝试加载FXML文档时遇到此错误:FXMLLoader.load无法解析为类型 这是我的密码:Java FXMLLoader.load无法解析为类型,java,javafx,fxml,scenebuilder,fxmlloader,Java,Javafx,Fxml,Scenebuilder,Fxmlloader,因此,我使用JavaFX的Scene Builder工具创建了一个FXML接口,并试图通过我的代码加载它。但是,我在尝试加载FXML文档时遇到此错误:FXMLLoader.load无法解析为类型 这是我的密码: import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Driver extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Parent root = new FXMLLoader.load(getClass().getResource("interface.fxml"));
Scene scene = new Scene(root, 600, 400);
primaryStage.setTitle("Wiki Scraper");
primaryStage.setScene(scene);
primaryStage.show();
}
}
我的FXML文档包含在最顶层的项目文件夹中
我做错了什么?试着这样把它分开:
FXMLLoader loader = new FXMLLoader(this.getClass().getResource("DefaultFrame.fxml"));
Parent root = (Parent) loader.load();
dfController = loader.getController();
问题是new FXMLLoader.load。您可以使用FXMLLoader的实例使用新的FXMLLoader.load调用load。。。或者使用FXMLLoader.load调用静态方法。。。