0
我有一個問題,遇到我想不通:東西是錯誤的,當我加載FXML文件在類的構造函數
public Attribution{
FXMLLoader loader;
Group tree;
Scene scene;
AttributionNodeController controller; // This is the corresponding controller
public Attribution() {
try {
System.out.println("Attribution constructor");
loader = new FXMLLoader(Attribution.class.getResource("/view/AttributionNode.fxml"));
tree = loader.load();
controller = loader.getController();
scene = new Scene(tree);
} catch (Exception e) {
}
}
}
而且,我步調試這個程序,
loader = new FXMLLoader(Attribution.class.getResource("/view/AttributionNode.fxml"));
此語句運行得很好,但後來,
tree = loader.load();
controller = loader.getController();
scene = new Scene(tree);
這三條語句將被刪除。
那麼,爲什麼會發生這種情況呢? 非常感謝你的提示!