JDK-8137244 : Empty Tree/TableView with CONSTRAINED_RESIZE_POLICY is not properly resized
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u60,jfx18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-09-17
  • Updated: 2024-01-10
  • Resolved: 2023-01-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
jfx21 b02Fixed
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Ubuntu 14,
Windows 7 64,
MacOs 10.10.5

A DESCRIPTION OF THE PROBLEM :
If I create a TreeTableView with ColumnResizePolicy == CONSTRAINED_RESIZE_POLICY, then I add there some data and then clear the table, columns will not respect ResizePolicy anymore.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Add data to the table
2. Clear the table
3. Try to resize the table

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Columns respect CONSTRAINED_RESIZE_POLICY
ACTUAL -
They don't

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;

/**
 * Created by kpasko on 19.08.15.
 */
public class Test2 extends Application {

	private TreeItem<Pojo> rootItem;

	@Override
	public void start(Stage primaryStage) {
        VBox root = new VBox();

		rootItem = new TreeItem<>();
		TreeTableView<Pojo> table = new TreeTableView<>();
		table.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
		table.setShowRoot(false);
		TreeTableColumn<Pojo, String> column = new TreeTableColumn<>("Column1");
		column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getValue().getValue()));
		table.getColumns().add(column);
		table.setRoot(rootItem);

        HBox buttonsBox = new HBox();
        Button fillTable = new Button("fill table");
        fillTable.setOnAction(e -> fillTable());
        Button clearTable = new Button("clear table");
        clearTable.setOnAction(e -> rootItem.getChildren().clear());
        buttonsBox.getChildren().addAll(fillTable, clearTable);

        root.getChildren().addAll(buttonsBox, table);
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.show();
	}

    private void fillTable() {
        rootItem.getChildren().add(new TreeItem<>(new Pojo("100")));
        rootItem.getChildren().add(new TreeItem<>(new Pojo("101")));
        rootItem.getChildren().add(new TreeItem<>(new Pojo("102")));
        rootItem.getChildren().add(new TreeItem<>(new Pojo("103")));
        rootItem.getChildren().add(new TreeItem<>(new Pojo("104")));
        rootItem.getChildren().add(new TreeItem<>(new Pojo("105")));
    }

	public static void main(String[] args) {
		launch(args);
	}

	private class Pojo {
		String value;

		public Pojo(String value) {
			this.value = value;
		}

		public String getValue() {
			return value;
		}
	}
}
---------- END SOURCE ----------



Edit:
Probably caused by an incomplete fix for RT-14855 / JDK-8113886
Comments
Changeset: be89e3e3 Author: Andy Goryachev <angorya@openjdk.org> Date: 2023-01-20 16:20:21 +0000 URL: https://git.openjdk.org/jfx/commit/be89e3e3c6c3a4479ee16b6e805a4a10fba6f7ab
20-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/991 Date: 2023-01-10 19:34:33 +0000
12-01-2023

Reproduced with jfx18. Applies to TreeTableView as well as TableView.
26-08-2022