-
Bug
-
Resolution: Fixed
-
P4
-
jfx11
-
b02
the row skin cell layout is completely broken if there's a padding on the row - below is an example for convenience, actually you can use whatever table you have handy ;)
As you can see, the layout is broken in both location and sizing of the cells. Culprit is TableRowSkinBase.layoutChildren(x, y, ....) which is doing the wrong thingy at several places:
@Override
protected void layoutChildren(double x, final double y, final double w, final double h) {
// offset x and width are adjusted to insets, so taking them into account
// again is most probably over-adjusting
final double horizontalPadding = snappedLeftInset() + snappedRightInset();
// adjusting the width for each column to the _row_ padding is
// definitely the wrong thing
double width;
for(each-column) {
width = cell.prefWidth(height) - horizontalPadding;
cell.resize(width, ...)
cell.relocate(x, ...)
x += width;
}
the very first cell has the correct position (because the param x is the correct offset), its width is too small by the rowPadding and the next cell is off in both location and width.
Didn't dig further, but this basic layout quirk might be (part?) of the reason that TreeTableRow layout is completely broken ...
The example:
public class BugTableBugRowPadding extends Application {
private Parent createContent() {
TableView<Locale> table = createPlainTable();
BorderPane content = new BorderPane(table);
return content;
}
private TableView<Locale> createPlainTable() {
TableView<Locale> table = new TableView<>(
FXCollections.observableArrayList(Locale.getAvailableLocales()));
table.getColumns().addAll(createColumn("displayLanguage"),
createColumn("displayCountry"), createColumn("displayLanguage"));
return table;
}
private TableColumn<Locale, String> createColumn(String property) {
TableColumn<Locale, String> column = new TableColumn<>(property);
column.setCellValueFactory(new PropertyValueFactory<>(property));
return column;
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(createContent()));
URL uri = getClass().getResource("rowpadding.css");
stage.getScene().getStylesheets().add(uri.toExternalForm());
stage.setTitle(FXUtils.version());
stage.show();
}
public static void main(String[] args) {
launch(args);
}
@SuppressWarnings("unused")
private static final Logger LOG = Logger
.getLogger(BugTableBugRowPadding.class.getName());
}
The css rowpadding.css:
.table-row-cell
{
-fx-padding: 0 20 0 20 ;
}
.nested-column-header
{
-fx-padding: 0 20 0 20 ;
}
As you can see, the layout is broken in both location and sizing of the cells. Culprit is TableRowSkinBase.layoutChildren(x, y, ....) which is doing the wrong thingy at several places:
@Override
protected void layoutChildren(double x, final double y, final double w, final double h) {
// offset x and width are adjusted to insets, so taking them into account
// again is most probably over-adjusting
final double horizontalPadding = snappedLeftInset() + snappedRightInset();
// adjusting the width for each column to the _row_ padding is
// definitely the wrong thing
double width;
for(each-column) {
width = cell.prefWidth(height) - horizontalPadding;
cell.resize(width, ...)
cell.relocate(x, ...)
x += width;
}
the very first cell has the correct position (because the param x is the correct offset), its width is too small by the rowPadding and the next cell is off in both location and width.
Didn't dig further, but this basic layout quirk might be (part?) of the reason that TreeTableRow layout is completely broken ...
The example:
public class BugTableBugRowPadding extends Application {
private Parent createContent() {
TableView<Locale> table = createPlainTable();
BorderPane content = new BorderPane(table);
return content;
}
private TableView<Locale> createPlainTable() {
TableView<Locale> table = new TableView<>(
FXCollections.observableArrayList(Locale.getAvailableLocales()));
table.getColumns().addAll(createColumn("displayLanguage"),
createColumn("displayCountry"), createColumn("displayLanguage"));
return table;
}
private TableColumn<Locale, String> createColumn(String property) {
TableColumn<Locale, String> column = new TableColumn<>(property);
column.setCellValueFactory(new PropertyValueFactory<>(property));
return column;
}
@Override
public void start(Stage stage) throws Exception {
stage.setScene(new Scene(createContent()));
URL uri = getClass().getResource("rowpadding.css");
stage.getScene().getStylesheets().add(uri.toExternalForm());
stage.setTitle(FXUtils.version());
stage.show();
}
public static void main(String[] args) {
launch(args);
}
@SuppressWarnings("unused")
private static final Logger LOG = Logger
.getLogger(BugTableBugRowPadding.class.getName());
}
The css rowpadding.css:
.table-row-cell
{
-fx-padding: 0 20 0 20 ;
}
.nested-column-header
{
-fx-padding: 0 20 0 20 ;
}
- relates to
-
JDK-8146406 Unexplainable gap between TableCell inside a TableView
- Open
- links to
-
Commit openjdk/jfx/b4d86bdf
-
Review openjdk/jfx/800
-
Review(master) openjdk/jfx/800