0

I'm a JavaFX beginner. I'm trying to do use FXML to create a basic layout. I started with a BorderPane and in the center I want to make two sections and was trying to use either an HBox or a Flow/Tile Pane.

I know it's possible: http://docs.oracle.com/javafx/2/layout/builtin_layouts.htm

But I don't know how to do it with FXML. I'm having trouble really finding any good info on it. Here's what I tried with an HBox:

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

But I get these errors:

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

Any suggestions would be greatly appreciated.

Puce
  • 37,247
  • 13
  • 80
  • 152
Chelsea
  • 335
  • 2
  • 13

1 Answers1

1

As the stack trace clearly states, LEFT is not a valid value for the alignment property of an HBox, which is expecting a Pos. Use "CENTER_LEFT", "TOP_LEFT", or "BOTTOM_LEFT", as needed.

James_D
  • 201,275
  • 16
  • 291
  • 322
  • Dang, thanks. These huge error outputs are hard for me to parse. I guess I'll just start looking at the end first. – Chelsea Feb 04 '17 at 20:35
  • @Chelsea They look scary but they're pretty easy to follow, on the whole, once you get past the "wall of text" fear. [This post](http://stackoverflow.com/q/3988788/2775450) is very useful in terms of understanding them. (And yes, one part of it is to separate them by the "Caused by" sections, and work from the last one upwards.) – James_D Feb 05 '17 at 00:59
  • Thanks for the link! (: – Chelsea Feb 18 '17 at 18:04