后,我有这个FXML文件,我就开始想填充组合框:FXML现场建设者无效的属性填充的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">
<children>
<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">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="1" />
<String fx:value="20" />
<String fx:value="300" />
</FXCollections>
</items>
</ComboBox>
</children>
</AnchorPane>
但自从我填充它,它不会SceneBuilder打开并显示此错误:
错误
java.io.IOException: javafx.fxml.LoadException: Invalid attribute. /C:/Users/BTAP/workspace/Tst/src/table/table.fxml:12
而且它不会加载我的应用程序:
Caused by: javafx.fxml.LoadException: FXCollections is not a valid type.
注
如果我删除它加载现场建设者的fx:factory="observableArrayList"
并显示警告,但仍然无法运行我的程序。
我不太明白,因为它与我在许多例子中看到的方式相同example1,example2,example3。
为什么我会收到此错误?它不应该工作吗?
我知道如何用代码填充元素,但我正在寻找FXML解决方案。
是> = 1有效的属性? –
错误在行12之前,即“FXCollections fx:factory =”observableArrayList“>”。即使我替换其他的html代码,它仍然不会加载。 – Mansueli