我遇到一个奇怪的问题,即javaFX没有到达我的构造函数,或者我的类的任何部分,没有定义错误的控制台输出。标题为“java”的应用程序打开,但不会响应任何关闭尝试,除非结束该过程。 JavaFX可以在我的计算机上运行,因为我可以在这种环境中运行其他应用程序。
当运行调试器时,它似乎没有达到或破坏构造函数,所以我的想法是它永远不会到达?
该问题的视频: https://www.youtube.com/watch?v=713PRbDKKzU
这是MainApp类:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class MainApp extends Application {
private Stage primaryStage;
private BorderPane rootLayout;
private Doublet doublet = new Doublet();
public MainApp() {}
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) throws Exception {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Doublets");
initRootLayout();
showGameLayout();
}
/**
* Initializes the root layout.
*/
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class
.getResource("view/RootLayout.fxml"));
rootLayout = (BorderPane) loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
primaryStage.setScene(scene);
// Give the controller access to the main app.
RootLayoutController controller = loader.getController();
controller.setMainApp(this);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}