Я пытаюсь создать fileChooser в файле fxml. Мой код выглядит следующим образом:Создать FileChooser в FXML
<HBox alignment="CENTER">
<Label text="Tower 1 Image" />
<TextField fx:id="tower1ImageField" />
<FileChooser fx:id ="tower1FileChooser" />
</HBox>
И контроллер считывает так:
public class HudBuilderController{
@FXML TextField tower1ImageField;
@FXML FileChooser tower1FileChooser;
File towerFile;
@FXML TextField tower2ImageField;
@FXML FileChooser tower2FileChooser;
}
Однако я получаю сообщение об ошибке, что я не понимаю:
Caused by: java.lang.IllegalArgumentException: Unable to coerce [email protected] 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 Я попытался создать экземпляр FileChooser внутри контроллера, но я думаю, что мне нужно добавить больше в файл fxml. Любая помощь? Благодаря!
Спасибо! Я думаю, что мне нужна кнопка, которая в прессе открывает файл выбора! – thb7