Affects JavaFX 8.0 b84
Appearently, if you put a ListView/TableView inside a VBox, it behaves very strange.
It has something to do with the VBox's minHeight/prefHeight/maxHeight.
The height calculation of the ListView seems to be wrong. Change the height values to see the effect.
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBoxBuilder;
import javafx.stage.Stage;
public class TestApp5 extends Application {
public static void main(String[] args) {
try {
launch(args);
} catch (Exception e) {
e.printStackTrace();
}
}
public void start(final Stage stage) throws Exception {
SplitPane splitPane = new SplitPane();
splitPane.setOrientation(Orientation.VERTICAL);
ListView<String> listView = new ListView<String>();
ObservableList<String> items = FXCollections.observableArrayList();
listView.setItems(items);
for (int i = 0; i < 30; i++) {
items.add(Integer.toString(i));
}
VBox root = new VBox();
VBox vBox = VBoxBuilder.create().children(listView).build();
splitPane.getItems().add(vBox);
Button button = new Button();
button.setPrefHeight(100);
splitPane.getItems().add(button);
// Change these values.
//vBox.setMinHeight(0);
vBox.setPrefHeight(100);
vBox.setMaxHeight(100);
//
root.getChildren().add(splitPane);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
Appearently, if you put a ListView/TableView inside a VBox, it behaves very strange.
It has something to do with the VBox's minHeight/prefHeight/maxHeight.
The height calculation of the ListView seems to be wrong. Change the height values to see the effect.
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBoxBuilder;
import javafx.stage.Stage;
public class TestApp5 extends Application {
public static void main(String[] args) {
try {
launch(args);
} catch (Exception e) {
e.printStackTrace();
}
}
public void start(final Stage stage) throws Exception {
SplitPane splitPane = new SplitPane();
splitPane.setOrientation(Orientation.VERTICAL);
ListView<String> listView = new ListView<String>();
ObservableList<String> items = FXCollections.observableArrayList();
listView.setItems(items);
for (int i = 0; i < 30; i++) {
items.add(Integer.toString(i));
}
VBox root = new VBox();
VBox vBox = VBoxBuilder.create().children(listView).build();
splitPane.getItems().add(vBox);
Button button = new Button();
button.setPrefHeight(100);
splitPane.getItems().add(button);
// Change these values.
//vBox.setMinHeight(0);
vBox.setPrefHeight(100);
vBox.setMaxHeight(100);
//
root.getChildren().add(splitPane);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
- relates to
-
JDK-8124606 GridPane layout of ListViews broken in Lombard
-
- Resolved
-