Kyllopardiun Kyllopardiun - 5 months ago 73
Java Question

FXML scene builder invalid attribute after filling ComboBox

I have this FXML file, where I tried to populate the ComboBox:

<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="650.0" minWidth="750.0" prefHeight="700.0" prefWidth="822.0" xmlns="" xmlns:fx="" fx:controller="table.Table">
<MenuButton fx:id="dateFilter" layoutX="6.0" layoutY="55.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="114.0" text="Date" />
<ComboBox fx:id="descriptionFilter" editable="true" layoutX="226.0" layoutY="55.0" prefHeight="25.0" prefWidth="204.0" promptText="Series Description">
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="20" />
<String fx:value="300" />

But since I populated it, it won't open on SceneBuilder and it displays this error:

Error javafx.fxml.LoadException: Invalid attribute.

And it won't load my Application:

Caused by: javafx.fxml.LoadException: FXCollections is not a valid type.


if I remove the
it loads on the scene builder and show a warning but still won't run my program.

And I don't quite understand since it's the same way as I saw in many examples example1, example2, example3.

Why am I getting this error? Shouldn't it work?

I know how to fill the elements by code, but I am looking for a FXML solution.


You need an import for the FXCollections class:

<?import javafx.collections.FXCollections ?>