我用以下内容编辑主FXML数据:fx:id =" spieler_tree" FX:ID =" karten_tree" FX:ID =" voelker_tree"
但是没有编辑它,它会抛出相同的异常。所以我对fxml有任何错误。我用场景生成器创建它,我没有太多exp。用FXML。
那里有任何重大错误吗?
异常
javafx.fxml.LoadException:
/C:/Users/Hades-User/Desktop/Projekte/MatchMaker%203.0/bin/matchMakerView/MatchMaker_TreeView2.fxml:7
/C:/Users/Hades-User/Desktop/Projekte/MatchMaker%203.0/bin/matchMakerView/MatchMaker_MainView.fxml:20
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.access$2600(Unknown Source)
at javafx.fxml.FXMLLoader$IncludeElement.constructValue(Unknown Source)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(Unknown Source)
at javafx.fxml.FXMLLoader.processStartElement(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at matchMakerMain.MatchMaker_Main.start(MatchMaker_Main.java:26)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/1036649994.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/1051754451.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1866685451.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/1775282465.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at matchMakerController.TreeView_Controller.<init>(TreeView_Controller.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.reflect.misc.ReflectUtil.newInstance(Unknown Source)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(Unknown Source)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(Unknown Source)
at javafx.fxml.FXMLLoader$Element.processStartElement(Unknown Source)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(Unknown Source)
at javafx.fxml.FXMLLoader.processStartElement(Unknown Source)
... 29 more
FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="matchMakerController.Main_Controller">
<children>
<SplitPane dividerPositions="0.19548872180451127" layoutX="152.0" layoutY="59.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="538.0" prefWidth="202.0">
<children>
<Accordion layoutY="14.0" prefHeight="500.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<panes>
<TitledPane animated="false" text="Spieler">
<content>
<fx:include fx:id="spieler_tree" source="MatchMaker_TreeView2.fxml" />
</content>
</TitledPane>
<TitledPane animated="false" text="Karten">
<content>
<fx:include fx:id="karten_tree" source="MatchMaker_TreeView3.fxml" />
</content>
</TitledPane>
<TitledPane animated="false" layoutX="10.0" layoutY="10.0" text="Völker">
<content>
<fx:include fx:id="voelker_tree" source="MatchMaker_TreeView4.fxml" />
</content>
</TitledPane>
<TitledPane animated="false" prefHeight="223.0" prefWidth="0.0" text="Einstellungen" />
</panes>
</Accordion>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TabPane layoutX="20.0" prefHeight="598.0" prefWidth="687.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab text="Match " />
<Tab text="Elo ">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>
</children>
</AnchorPane>
</items>
</SplitPane>
</children>
</AnchorPane>
FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="matchMakerController.TreeView_Controller">
<children>
<TreeView fx:id="spieler_tree" layoutX="2.0" prefHeight="497.0" prefWidth="203.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
public class TreeView_Controller {
private Main_Controller mainController;
@FXML private TreeView<Object> spieler_tree;
@FXML private TreeView<Object> karten_tree;
@FXML private TreeView<Object> voelker_tree;
private static CheckBoxTreeItem<Object> spieler_Root_aktiv, spieler_Root_Inaktiv, spieler_MainRoot;
private static CheckBoxTreeItem<Object> karten_Root_Landkarte, karten_Root_Wasserkarte,karten_Root_Funkarten, karten_MainRoot;
private static CheckBoxTreeItem<Object> voelker_Root_NonPaladin, voelker_Root_Paladin, voelker_MainRoot;
public TreeView_Controller(){
//Root für die Spieler in der Treeview
spieler_MainRoot = new CheckBoxTreeItem<Object>("Spieler");
spieler_Root_aktiv = new CheckBoxTreeItem<Object>("Spieler(aktiv)");
spieler_Root_Inaktiv = new CheckBoxTreeItem<Object>("Spieler(inaktiv)");
//Root für die Karten in der Treeview
karten_MainRoot = new CheckBoxTreeItem<Object>("Karten");
karten_Root_Landkarte = new CheckBoxTreeItem<Object>("Landkarten");
karten_Root_Wasserkarte = new CheckBoxTreeItem<Object>("Wasserkarten");
karten_Root_Funkarten = new CheckBoxTreeItem<Object>("Fun-Maps");
//Root für die Karten in der Treeview
voelker_MainRoot = new CheckBoxTreeItem<Object>("Völker");
voelker_Root_Paladin = new CheckBoxTreeItem<Object>("Paladin");
voelker_Root_NonPaladin = new CheckBoxTreeItem<Object>("NonPaladin");
//Damit die Roots ausgeklappt angezeigt werden
spieler_MainRoot.setExpanded(true);
spieler_Root_aktiv.setExpanded(true);
karten_MainRoot.setExpanded(true);
voelker_MainRoot.setExpanded(true);
//Damit die gängisten Einträge direkt angeklickt sind
karten_Root_Landkarte.setSelected(true);
karten_Root_Wasserkarte.setSelected(true);
voelker_Root_Paladin.setSelected(true);
voelker_Root_NonPaladin.setSelected(true);
spieler_MainRoot.getChildren().addAll(spieler_Root_aktiv,spieler_Root_Inaktiv);
karten_MainRoot.getChildren().addAll(karten_Root_Landkarte,karten_Root_Wasserkarte,karten_Root_Funkarten);
voelker_MainRoot.getChildren().addAll(voelker_Root_Paladin,voelker_Root_NonPaladin);
//TreeCell sind für die Checkboxes im Treeview
spieler_tree.setCellFactory(CheckBoxTreeCell.forTreeView());
karten_tree.setCellFactory(CheckBoxTreeCell.forTreeView());
voelker_tree.setCellFactory(CheckBoxTreeCell.forTreeView());
fillPlayer();
fillMap();
fillNation();
spieler_tree.setRoot(spieler_MainRoot);
karten_tree.setRoot(karten_MainRoot);
voelker_tree.setRoot(voelker_MainRoot);
}
}
&#13;