2017-02-04 2 views
0

Ich bin ein JavaFX Anfänger. Ich versuche mit FXML ein einfaches Layout zu erstellen. Ich begann mit einem BorderPane und in der Mitte wollte ich zwei Abschnitte machen und versuchte entweder eine HBox oder einen Flow/Tile Pane zu verwenden.Setzen Sie JavaFX FlowPane in BorderPane mit FXML

Ich weiß, es ist möglich: http://docs.oracle.com/javafx/2/layout/builtin_layouts.htm

Aber ich weiß nicht, wie es mit FXML zu tun. Ich habe Probleme, wirklich gute Informationen darüber zu finden. Hier ist, was ich mit einem HBox versucht:

<BorderPane id="main" prefHeight="500" prefWidth="500" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inventorymanagementsystem.FXMLDocumentController">  
    <top> 
     <Label text="Label 1" /> 
    </top> 
    <center> 
     <HBox alignment="LEFT"> 
      <children> 
       <Label text="Label 2" /> 
      </children> 
     </HBox> 
    </center> 
</BorderPane> 

Aber ich bekomme diese Fehler:

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:497) 
    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:497) 
    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$152(LauncherImpl.java:182) 
    at com.sun.javafx.application.LauncherImpl$$Lambda$51/1343441044.run(Unknown Source) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: javafx.fxml.LoadException: 
file:/Users/chelseacamper/NetBeansProjects/InventoryManagementSystem/dist/run174493937/InventoryManagementSystem.jar!/inventorymanagementsystem/FXMLDocument.fxml:18 

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108) 
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101) 
    at inventorymanagementsystem.InventoryManagementSystem.start(InventoryManagementSystem.java:22) 
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863) 
    at com.sun.javafx.application.LauncherImpl$$Lambda$54/2067027202.run(Unknown Source) 
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326) 
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/355629945.run(Unknown Source) 
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295) 
    at com.sun.javafx.application.PlatformImpl$$Lambda$49/147927901.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294) 
    at com.sun.javafx.application.PlatformImpl$$Lambda$48/1915503092.run(Unknown Source) 
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) 
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 
    at com.sun.javafx.fxml.BeanAdapter.coerce(BeanAdapter.java:509) 
    at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:258) 
    at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:54) 
    at javafx.fxml.FXMLLoader$Element.applyProperty(FXMLLoader.java:508) 
    at javafx.fxml.FXMLLoader$Element.processValue(FXMLLoader.java:359) 
    at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:321) 
    at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:231) 
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:763) 
    at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2827) 
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2536) 
    ... 18 more 
Caused by: 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:497) 
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) 
    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:497) 
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) 
    at com.sun.javafx.fxml.BeanAdapter.coerce(BeanAdapter.java:505) 
    ... 27 more 
Caused by: java.lang.IllegalArgumentException: No enum constant javafx.geometry.Pos.LEFT 
    at java.lang.Enum.valueOf(Enum.java:238) 
    at javafx.geometry.Pos.valueOf(Pos.java:40) 
    ... 38 more 
Exception running application inventorymanagementsystem.InventoryManagementSystem 
Java Result: 1 

Irgendwelche Vorschläge wäre sehr dankbar.

Antwort

1

Da die Stack-Trace eindeutig fest, LEFT ist kein gültiger Wert für die alignment property ein HBox, die ein Pos erwartet. Verwenden Sie je nach Bedarf "CENTER_LEFT", oder "BOTTOM_LEFT".

+0

Dang, danke. Diese großen Fehlerausgaben sind für mich schwer zu parsen. Ich denke, ich fange einfach erst an, das Ende zu betrachten. – Chelsea

+0

@Chelsea Sie sehen unheimlich aus, aber im Großen und Ganzen sind sie ziemlich leicht zu verstehen, sobald man die Angst vor der "Mauer aus Text" überwunden hat. [Dieser Beitrag] (http://stackoverflow.com/q/3988788/2775450) ist sehr nützlich, um sie zu verstehen. (Und ja, ein Teil davon ist, sie durch die Abschnitte "verursacht durch" zu trennen, und arbeiten von der letzten aufwärts.) –

+0

Danke für den Link! (: – Chelsea

Verwandte Themen