2017-09-17 3 views
1

J'ai ajouté deux vues d'image dans une disposition de pile que j'ai créée mais lorsque j'essaie d'ajouter un noeud de bouton dans mon StackPane mise en page, tandis que les images fonctionnent très bien, le bouton ne permet pas l'exécution du programme et lance cette exception que je ne peux pas comprendre:Ajout d'un noeud Button dans javaFX 8 déclenche une exception - javafx.fxml.LoadException: identifiant non valide

> > Exception in Application start method 
java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) 
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) 
Caused by: java.lang.RuntimeException: Exception in Application start method 
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) 
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) 
at java.lang.Thread.run(Thread.java:748) 
Caused by: javafx.fxml.LoadException: Invalid identifier. 
/C:/Users/Steli/Dropbox/Java_Projects/IntelliJ%20IDEA%20Projects/DokkanCardsPreview/out/production/DokkanCardsPreview/fxml/home.fxml:33 
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597) 
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103) 
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:901) 
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971) 
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220) 
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744) 
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) 
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) 
at com.spdesigns.dokkancardspreview.Main.start(Main.java:13) 
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) 
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) 
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) 
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) 
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) 
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) 
... 1 more 
Exception running application com.spdesigns.dokkancardspreview.Main 

Process finished with exit code 1 

maintenant, voici mon fichier FXML:

<?xml version="1.0" encoding="UTF-8"?> 

<?import java.lang.*?> 
<?import java.util.*?> 
<?import javafx.scene.*?> 
<?import javafx.scene.control.*?> 
<?import javafx.scene.layout.*?> 

<?import javafx.scene.image.ImageView?> 
<?import javafx.scene.image.Image?> 
<GridPane xmlns="http://javafx.com/javafx" 
      xmlns:fx="http://javafx.com/fxml" 
      fx:controller="com.spdesigns.dokkancardspreview.controllers.home" 
      stylesheets="/css/main.css" 
      fx:id="container" 
      prefHeight="400.0" prefWidth="600.0"> 

    <children> 
     <Label text="Cards List" fx:id="listTitle" GridPane.rowIndex="0" GridPane.columnIndex="0"/> 
     <HBox fx:id="listViewAndImageContainer"> 
       <children> 
        <ListView fx:id="listView" GridPane.rowIndex="1" GridPane.columnIndex="0" prefHeight="600"/> 
       </children> 
      <children> 
       <StackPane fx:id="ImageAndArrowButtonContainer"> 
        <children> 
         <ImageView fx:id="imageView" fitWidth="400" fitHeight="600"> 
          <Image url="/images/image_placeholder.png" fx:id="image"/> 
         </ImageView> 
         <ImageView fx:id="arrow" fitHeight="40" fitWidth="60"> 
          <Image url="/images/arrow.png"/> 
         </ImageView> 
         <Button fx:id="arrow-button" prefHeight="40" prefWidth="60" text="test"></Button> 
        </children> 
       </StackPane> 
      </children> 
     </HBox> 
    </children> 

</GridPane> 

Et c'est main.java-coller car il est mentionné dans l'exception-:J'espère que quelqu'un ici peut m'aider à résoudre ce problème (c'est probablement quelque chose de "stupide" mais quand même ... Je n'arrive pas à trouver la solution à cette exception!

Répondre

2

Vous ne pouvez pas utiliser le tiret (-) dans l'ID car cela signifie moins une opération. Remplacez-le par un trait de soulignement (_) ou utilisez camelCase.

+0

Merci beaucoup, cela a résolu le problème! Je vais le garder à l'esprit à partir de maintenant! –