Reputation: 1
there is my fxml file:
<AnchorPane fx:id="anch" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ListView fx:id="list" layoutX="200.0" layoutY="7.0" prefHeight="393.0" prefWidth="200.0" />
</children>
</AnchorPane>
and controllerfile :
@FXML
private ListView<String> list;
@FXML
private AnchorPane anch;
ObservableList<String> li = FXCollections.observableArrayList("red","blue","yellow");
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
list.setItems(li);
}
When I run the program the program, it only shows the empty list.
Upvotes: 0
Views: 118
Reputation: 584
Miss fx:controller
in FXML
Ex:
<AnchorPane id="AnchorPane" prefHeight="380.0" prefWidth="387.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="PackageName.ControllerFileName">
Upvotes: 3