JAVAFX

ListView

Article by:
Date Published:
Last Modified:

Contents

Creating A List View In FXML

Although this would not be the standard way to do it (normally a ListView would be populated by the backend Java code), you can create a ListView node using pure fxml code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<ListView>
    <items>
        <FXCollections fx:factory="observableArrayList">
            <String fx:value="One"/>
            <String fx:value="Two"/>
            <String fx:value="Three"/>
            <String fx:value="Four"/>
            <String fx:value="Five"/>
        </FXCollections>
    </items>
</ListView>

Note that is important to wrap the String objects inside a ObservableArrayList object.


Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Tags

comments powered by Disqus