RFR: 8298728: Cells in VirtualFlow jump after resizing

Andy Goryachev angorya at openjdk.org
Wed Dec 14 20:57:16 UTC 2022


On Wed, 14 Dec 2022 10:03:29 GMT, Johan Vos <jvos at openjdk.org> wrote:

> When recalculating sizes, we often don't want the current index and/or offset to change.
> 
> Allow to fix the index/offset when doing recalculations.
> 
> Fix JDK-8298728

I am trying to understand what the behavioral difference is between this branch and the current master.  The ticket JDK-8298728 does not seem to specify the exact scenario, so I tried the following code with the large model (3000 lines) with a wrapping Text as graphic node.  Resizing both vertically and horizontally produces what I this is identical result where the top visible selected cell scrolls out of the view in both cases.

cell factory:

                       TableColumn<String,String> c = new TableColumn<>();
                        table.getColumns().add(c);
                        c.setText("C" + table.getColumns().size());
                        c.setCellValueFactory((f) -> new SimpleStringProperty(describe(c)));
                        c.setCellFactory((r) -> {
                            return new TableCell<>() {
                                @Override
                                protected void updateItem(String item, boolean empty) {
                                    super.updateItem(item, empty);
                                    Text t = new Text("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n2\n3\n");
                                    t.wrappingWidthProperty().bind(widthProperty());
                                    setPrefHeight(USE_COMPUTED_SIZE);
                                    setGraphic(t);
                                }
                            };
                        });



I can attache the whole program to the jira ticket.

modules/javafx.controls/src/main/java/javafx/scene/control/skin/VirtualFlow.java line 2327:

> 2325:         double cellLength = getOrCreateCellSize(index);
> 2326:         if (index > 0) getOrCreateCellSize(index - 1);
> 2327:         if (index < getCellCount() -1) getOrCreateCellSize(index + 1);

I think it's better to keep one statement per line - for stepping through in a debugger, and also if an exception gets thrown it will be easier to see where.

-------------

PR: https://git.openjdk.org/jfx/pull/974


More information about the openjfx-dev mailing list