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="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" 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:


java.io.IOException: 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 fx:factory="observableArrayList" 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.

5/23/2017 11:59:57 AM

Accepted Answer

You need an import for the FXCollections class:

<?import javafx.collections.FXCollections ?>
6/24/2014 11:27:25 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow