JDK-8090112 : Wrong TableView headers width when using TableView.CONSTRAINED_RESIZE_POLICY
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2013-10-31
  • Updated: 2023-01-05
  • Resolved: 2023-01-05
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
tbdResolved
Related Reports
Blocks :  
Duplicate :  
Description
In java 8 from b113 (earlier also) I found bug in TableView.
When ColumnResizePolicy is setted to CONSTRAINED_RESIZE_POLICY and table have data that is not fit in available tableview's height (vertical scroll is visible) then headers have improper width - but only when TableView is not focused. When TableView get focus then headers are getting proper width.

TableView before get focus:
http://imageshack.us/a/img841/6853/j9u9.png 

TableView after:
http://imageshack.us/a/img43/922/169f.png

I have also created thread in Oracle forum that is explaining bug and you can get example app source code from this place: https://forums.oracle.com/message/11251219#11251219
Comments
A duplicate of JDK-8293119. With JDK-8293119, the CONSTRAINED_RESIZE_POLICY correctly resizes headers when the table is populated.
05-01-2023

Yes. If you can find the bug report that fixed this failure, then you can close it as a duplicate. Otherwise, we should at least determine whether the bug is still present in a recent 11.0.x or 8 update release before closing it out.
26-08-2022

Unable to reproduce with jfx18 on Mac OS X. Can we close this ticket?
26-08-2022

The issue is, I believe, due to the appearance of the ScrollBar. If the numbers of items is reduced to 20 (rather than 200), no scroll bar is shown, and therefore the columns align with the header properly. I will look into how to resolve this ASAP.
20-01-2015

This issue is currently targeted to be fixed in 9. I retargeted the issue from 8u20 to 9 on January 28th, 2014, when I first triaged this issue.
24-07-2014

The bug which was said will be taken care in java 1.8_20 release is still not resolved. I could replicate the issue with jdk 1.8_20 early access release as well
24-07-2014

I am also facing similar issue..
29-05-2014

Thanks, I can reproduce this issue. Test code from Oracle forum: import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.MapValueFactory; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; import javafx.stage.Stage; import java.util.*; public class Main extends Application { @Override public void start(Stage primaryStage) { final AnchorPane root = new AnchorPane(); root.setPadding(new Insets(10)); final HBox controls = new HBox(5); final Button getDataButton = new Button("load data"); final TextField textField = new TextField(); final TableView<Map> table = new TableView<>(); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); getDataButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { DataSource dataSource = new DataSource(); table.getColumns().clear(); table.getColumns().addAll(dataSource.getTableColumns()); table.setItems(dataSource.getQueryResult()); } }); controls.getChildren().addAll(getDataButton, textField); AnchorPane.setTopAnchor(controls, 10.0); AnchorPane.setLeftAnchor(controls, 10.0); AnchorPane.setRightAnchor(controls, 10.0); AnchorPane.setTopAnchor(table, 45.0); AnchorPane.setRightAnchor(table, 10.0); AnchorPane.setLeftAnchor(table, 10.0); AnchorPane.setBottomAnchor(table, 10.0); root.getChildren().addAll(controls, table); primaryStage.setScene(new Scene(root, 1000, 1000)); primaryStage.show(); } public static class DataSource { public List<TableColumn<Map, Object>> getTableColumns() { TableColumn<Map, Object> idColumn = new TableColumn<>("ID"); idColumn.setCellValueFactory(new MapValueFactory<Object>("ID")); TableColumn<Map, Object> nameColumn = new TableColumn<>("NAME"); nameColumn.setCellValueFactory(new MapValueFactory<Object>("NAME")); return Arrays.asList(idColumn, nameColumn); } public ObservableList<Map> getQueryResult() { List<Map> result = new ArrayList<>(); for (int i = 0; i < 200; i++) { Map<String, Object> row = new HashMap<>(); row.put("ID", i); row.put("NAME", "Name " + i); result.add(row); } return FXCollections.observableArrayList(result); } } public static void main(String[] args) { launch(args); } }
28-01-2014

Fix incorrect "affects" version.
06-11-2013