Summary
Add a new protected method in TableColumnHeader
allowing developers to override the algorithm used for resizing a column to fit its content.
Problem
The method resizeColumnToFitContent(TableViewSkinBase<?,?,?,?,?> tableSkin, TableColumnBase<?,?> tc, int maxRows)
in javafx.scene.control.skin.TableSkinUtils
cannot be accessed by a person overriding the TableView
. Therefore, it is not possible for a developer to provide a custom implementation for a column being resized.
Solution
A solution is to remove the implementation from TableSkinUtils
and move it somewhere, where it could be overridden.
A 1st solution is to revert back to java 8 API and place this method in TableViewSkinBase
but that would introduce an abstract method.
A 2nd solution is to naturally place this method in the TableColumnHeader
class since it's this specific class that will call this method.
Specification
The following API is added:
javafx/scene/control/skin/TableColumnHeader.java
:
/**
* Resizes this {@code TableColumnHeader}'s column to fit the width of its content.
*
* @implSpec The resulting column width for this implementation is the maximum of the preferred width of the header
* cell and the preferred width of the first {@code maxRow} cells.
* <p>
* Subclasses can either use this method or override it (without the need to call {@code super()}) to provide their
* custom implementation (such as ones that exclude the header, exclude {@code null} content, compute the minimum
* width, etc.).
*
* @param maxRows the number of rows considered when resizing. If -1 is given, all rows are considered.
* @since 14
*/
protected void resizeColumnToFitContent(int maxRows) {
- csr of
-
JDK-8207957 TableSkinUtils should not contain actual code implementation
-
- Resolved
-