package javatest; import javafx.scene.control.*; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Orientation; import javafx.scene.Group; public class ListViewNodeSizeIssue extends Application { public static void main(String[] args) { ListViewNodeSizeIssue.launch(args); } Stage appFrame; ListView listView = new ListView(); Scene scene; VBox vBox1; @Override public void start(Stage stage) throws Exception { appFrame = stage; vBox1 = new VBox(10.0); ObservableList listItems = FXCollections.observableArrayList(); for (int i = 1; i <= 6; i++) { Button button = new Button("Button " + i); button.setId("Button " + i); listItems.add(button); } for (int i = 1; i <= 6; i++) { TextBox tb = new TextBox("TextBox " + i); tb.setId("TextBox " + i); listItems.add(tb); } listView.getItems().clear(); listView.getItems().addAll(listItems); listView.setOrientation(Orientation.VERTICAL); listView.setPrefWidth(4 * 400 / 5); listView.setPrefHeight(400 - 4 * 10.0); vBox1.setLayoutX(20.0F); vBox1.getChildren().addAll(listView); scene = new Scene(new Group(), 400, 400); ((Group) scene.getRoot()).getChildren().clear(); ((Group) scene.getRoot()).getChildren().addAll(vBox1); appFrame.setScene(scene); appFrame.setVisible(true); listView.requestFocus(); } }