2014-01-23 9 views
13

Vor kurzem habe ich installiert Java 8 Build 124 für meine JavaFX-Anwendung, und ich begann, diese Fehler bekommen:Wurzel hat nicht Fehler mit Java 8 Eclipse-gesetzt wurde

javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load. 
/Users/jonathan/Projects/Dominion/target/classes/dominion/application/controller/main_overview_tab.fxml:13 

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2613) 
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:104) 
at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1320) 
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740) 
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2723) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) 
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) 
at dominion.application.controller.MainOverviewTab.initView(MainOverviewTab.java:64) 
at dominion.application.controller.MainOverviewTab.initializeController(MainOverviewTab.java:55) 
at dominion.application.controller.GameSetupController.<init>(GameSetupController.java:37) 
at dominion.application.controller.DashboardController.<init>(DashboardController.java:40) 
at dominion.application.controller.MainController.<init>(MainController.java:37) 
at dominion.application.Dominion.start(Dominion.java:18) 
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837) 
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335) 
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301) 
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298) 
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) 

javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load. 
/Users/jonathan/Projects/Dominion/target/classes/dominion/application/controller/players_tab.fxml:13 

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2613) 
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:104) 
at javafx.fxml.FXMLLoader$RootElement.constructValue(FXMLLoader.java:1320) 
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740) 
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2723) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) 
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) 
at dominion.application.controller.PlayersTab.initView(PlayersTab.java:46) 

Meine Anwendung läuft unter Java nur gut 7 baut 40 und 51, aber nicht unter Java 8 Build 124. Hier sind die ersten paar Zeilen meiner main_overview_tab.fxml Datei:

<fx:root type="javafx.scene.layout.AnchorPane" id="AnchorPane" fx:id="content" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-1.0" minWidth="-1.0" prefHeight="600.0" prefWidth="1000.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"> 
<children> 
<VBox prefHeight="-1.0" prefWidth="-1.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"> 
    <children> 
    <HBox prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS"> 
     <children> 
     <VBox id="playersVBox" prefHeight="-1.0" prefWidth="-1.0" spacing="40.0" HBox.hgrow="ALWAYS"> 
      <children> 
      <Label text="Players"> 
       <font> 
       <Font size="18.0" fx:id="x3" /> 
       </font> 
       <VBox.margin> 
       <Insets /> 
       </VBox.margin> 
      </Label> 

Diese Frage ist sehr ähnlich, aber offenbar nicht meine Situation helfen: JavaFX SceneBuilder 2.0 doesn't open FXML for custom components with fx:root as main layout tag.

EDIT: Code FXML

public class MainOverviewTab extends Tab implements IObserver { 
    @FXML public AnchorPane content; 

    private SingleGameSettings gameSettings; 
    private List<ImageView> overviewImages; 

    public MainOverviewTab() { 
    } 

    public void initializeController(SingleGameSettings gameSettings) { 
     this.gameSettings = gameSettings; 
     this.gameSettings.registerObserver(this); 

     initView(); 
    } 

    private void initView() { 
     FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("main_overview_tab.fxml")); 
     fxmlLoader.setRoot(content); 
     fxmlLoader.setController(this); 

     try { 
      fxmlLoader.load(); 
     } 
     catch (Exception e) { 
      e.printStackTrace(); 
     } 

     this.setText("Overview Game"); 
     this.setContent(content); 

    } 
    ... 
+0

Zeigen Sie den Java-Code zu laden Die fxml – tomsontom

+4

Entfernung von von fxml löst das Problem: http://Stackoverflow.com/a/21076712/3231870 – Newion

Antwort

15

uncheck fx zu laden: root Konstrukt aus Szene Builder-> Dokument -> Controller oder Entfernen von Code von fxml Datei

+0

es funktioniert ich entfernte unmarked von Szene Builder – Zcon

+0

es funktionierte auch für mich. Stellen Sie nur sicher, dass Sie Project> Clean .. auf Eclipse ausführen. Vielen Dank! – ashlrem

Verwandte Themen