I'm trying to create a fileChooser within an fxml file. My code looks like this:
<HBox alignment="CENTER">
<Label text="Tower 1 Image" />
<TextField fx:id="tower1ImageField" />
<FileChooser fx:id ="tower1FileChooser" />
</HBox>
And the controller reads like this:
public class HudBuilderController{
@FXML TextField tower1ImageField;
@FXML FileChooser tower1FileChooser;
File towerFile;
@FXML TextField tower2ImageField;
@FXML FileChooser tower2FileChooser;
}
However, I'm getting an error that I don't understand:
Caused by: java.lang.IllegalArgumentException: Unable to coerce javafx.stage.FileChooser@5e85f35 to class javafx.scene.Node.
at com.sun.javafx.fxml.BeanAdapter.coerce(Unknown Source)
at javafx.fxml.FXMLLoader$Element.add(Unknown Source)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(Unknown Source)
at javafx.fxml.FXMLLoader.processEndElement(Unknown Source)
... 26 more
I've tried instantiating the FileChooser within the controller but I think I need to add more to the fxml file. Any help? Thanks!