2017-09-17 10 views
1

작성한 스택 판 레이아웃에 두 개의 이미지 뷰를 추가했지만 StackPane 내부에 버튼 노드를 추가하려고합니다. 이미지가 잘 작동하는 동안 레이아웃은,이 버튼은 프로그램을 실행할 수 있도록 내가 알아낼 수 없습니다이 예외가 발생하지 않습니다javaFX 8에 Button 노드를 추가하면 예외가 throw됩니다 - javafx.fxml.LoadException : 잘못된 식별자

> > 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 

을 지금이 내 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> 

을 그리고 이것은 메인입니다. 예외적으로 언급 되었기 때문에 자바 - 붙여 넣기 :

package com.spdesigns.dokkancardspreview; 

import javafx.application.Application; 
import javafx.fxml.FXMLLoader; 
import javafx.scene.Parent; 
import javafx.scene.Scene; 
import javafx.stage.Stage; 



public class Main extends Application { @Override 
    public void start(Stage primaryStage) throws Exception{ 
     Parent root = FXMLLoader.load(getClass().getResource("/fxml/home.fxml")); 
     primaryStage.setTitle("Dokkan Battle Card Preview"); 
     primaryStage.setScene(new Scene(root, 900, 700)); 
     primaryStage.setResizable(false); 
     primaryStage.show(); 
    } 


    public static void main(String[] args) { 
     launch(args); 
    } 
} 

여기에있는 누군가가이 문제를 해결하는 데 도움이 될 수 있기를 바랍니다. (아마 "어리석은"것이지만 여전히 ...이 예외에 대한 해결책을 찾지 못했습니다!

답변

2

빼기 작업을 의미하므로 대시 (-)를 사용할 수 없습니다. 밑줄 (_)로 바꾸거나 camelCase를 사용하십시오.

+0

대단히 고맙습니다. 문제가 해결되었습니다. 앞으로도 계속 염두에 둘 것입니다! –