FULL PRODUCT VERSION :
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The header of a TableView/TreeTableView is not resized correctly when in constrained resize mode and the items of the TableView are cleared. The following will reproduce the problem. The column is not resized with the window after the table is empty.
public class App2 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
Pane root = new StackPane();
TableView<String> tableView = new TableView<>();
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
final TableColumn<String, String> column = new TableColumn<>();
tableView.getColumns().add(column);
column.setCellValueFactory(param -> new SimpleStringProperty("Hello"));
final ObservableList<String> items = FXCollections.observableArrayList("1", "2", "3");
tableView.setItems(items);
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(5), event -> items.clear()));
timeline.play();
root.getChildren().add(tableView);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
The problem is within the layoutChildren() method in TableViewSkinBase which does not re-layout the inner VirtualFlow of the table when the TableView is empty. This later leads to problems in the updateContentWidth() method where the width of a column is based on the width of the VirtualFlow which still has its old value.
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The header of a TableView/TreeTableView is not resized correctly when in constrained resize mode and the items of the TableView are cleared. The following will reproduce the problem. The column is not resized with the window after the table is empty.
public class App2 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage primaryStage) throws Exception {
Pane root = new StackPane();
TableView<String> tableView = new TableView<>();
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
final TableColumn<String, String> column = new TableColumn<>();
tableView.getColumns().add(column);
column.setCellValueFactory(param -> new SimpleStringProperty("Hello"));
final ObservableList<String> items = FXCollections.observableArrayList("1", "2", "3");
tableView.setItems(items);
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(5), event -> items.clear()));
timeline.play();
root.getChildren().add(tableView);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}
The problem is within the layoutChildren() method in TableViewSkinBase which does not re-layout the inner VirtualFlow of the table when the TableView is empty. This later leads to problems in the updateContentWidth() method where the width of a column is based on the width of the VirtualFlow which still has its old value.
REPRODUCIBILITY :
This bug can be reproduced always.
- blocks
-
JDK-8292810 ☂ CONSTRAINED_RESIZE_POLICY issues
- Resolved
- duplicates
-
JDK-8137244 Empty Tree/TableView with CONSTRAINED_RESIZE_POLICY is not properly resized
- Resolved