後,我有這個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