Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8178297

TableView scrolls slightly when adding new elements

    XMLWordPrintable

Details

    • generic
    • generic

    Backports

      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 ----------

        Attachments

          Issue Links

            Activity

              People

                jpereda Jose Pereda
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: