JDK-8178297 : TableView scrolls slightly when adding new elements
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u20,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2017-04-06
  • Updated: 2022-03-01
  • Resolved: 2020-10-12
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.
JDK 8 Other
8u321Fixed openjfx11.0.10Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
'Version '1.8.0_121' Home '/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre'

ADDITIONAL OS VERSION INFORMATION :
macOS Sierra
Version 10.12.3

A DESCRIPTION OF THE PROBLEM :
When inserting items into a TableView the following issues are observed:

1. With TableView.getSelectionModel().setCellSelectionEnabled(true), the selection flashes on each insert.

2. If you scroll the table slightly and then stop scrolling, the table view does not stop scrolling. You can see the table view scroll slowly upwards as new items are inserted.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case which inserts items into the TableView on a timer.
Scroll down slightly and select a cell. 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The cell shouldn't flash and the table should not scroll slowly upwards.
ACTUAL -
The selected cell flashes and the table view scrolls slowly upwards.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.util.Duration;
 
public class TableViewSample extends Application {
 
    private final TableView<String> table = new TableView<>();
    public static void main(String[] args) {
        launch(args);
    }
 
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setTitle("Table View Sample");
        stage.setWidth(300);
        stage.setHeight(500);
 
        final Label label = new Label("Address Book");
        label.setFont(new Font("Arial", 20));
 
        table.setEditable(true);
        table.getSelectionModel().setCellSelectionEnabled(true);
        table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
 
        TableColumn<String, String> column = new TableColumn<>("First Name");
        column.setCellValueFactory(value -> new SimpleStringProperty(value.getValue()));
        
        table.getColumns().add(column);
 
        final VBox vbox = new VBox();
        vbox.setSpacing(5);
        vbox.setPadding(new Insets(10, 0, 0, 10));
        vbox.getChildren().addAll(label, table);
 
        ((Group) scene.getRoot()).getChildren().addAll(vbox);
 
        stage.setScene(scene);
        stage.show();
        
        Timeline timeline = new Timeline(new KeyFrame(Duration.millis(100),ae -> timerFired()));
        timeline.setCycleCount(Animation.INDEFINITE);
        timeline.play();
    }

    private void timerFired()
    {
        table.getItems().add("Flashes & Scrolling");
    }
}
---------- END SOURCE ----------


Comments
Changeset: 205e4b95 Author: Jose Pereda <jpereda@openjdk.org> Date: 2020-10-12 08:21:59 +0000 URL: https://git.openjdk.java.net/jfx/commit/205e4b95
12-10-2020

Adding in comment from Danny Gonzalez who emailed me: "This seems to be caused by the code in VirtualFlow starting at 1159 where the function adjustPixelAmount is being called with floating point values. Take a look at the firstCellOffset and viewportTopToCellTop double variables. We have temporarily fixed this by rounding these values to integers."
26-04-2017

Changing the synopsis to match the second problem as the first problem is tracked by JDK-8177945.
07-04-2017

Reporter has observed 2 issues: 1. With TableView.getSelectionModel().setCellSelectionEnabled(true), the selection flashes on each insert. 2. If you scroll the table slightly and then stop scrolling, the table view does not stop scrolling. You can see the table view scroll slowly upwards as new items are inserted. First one is duplicate of JDK-8177945 but not closing as duplicate, since second one is not reported in the original. Its again a regression as it is introduced in 8u20 of windows. Moving this to JDK for the development team's evaluation.
07-04-2017