<ListView>
<items>
<FXCollections fx:factory="データの種類">
……データの内容……
</FXCollections>
</items>
</ListView>
<FXCollections fx:factory="observableArrayList">そして、この中に<String>タグを使って表示するテキストを指定しています。単純なテキストの値ならばこれで表示できます。
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
<?xml version="1.0" encoding="UTF-8"?> <?language javascript?> <?import java.lang.*?> <?import java.net.URL ?> <?import javafx.scene.text.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.collections.FXCollections?> <BorderPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.tuyano.libro.AppController"> <stylesheets> <URL value="@app.css" /> </stylesheets> <top> <Label fx:id="label1" text="This is FXML!" /> </top> <center> <ListView fx:id="list1"> <items> <FXCollections fx:factory="observableArrayList"> <String fx:value="Windows" /> <String fx:value="Mac OS" /> <String fx:value="Linux" /> </FXCollections> </items> </ListView> </center> <bottom> <Button text="Click" fx:id="btn1" /> </bottom> </BorderPane>
次へ >> |