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

TableView Data disappears when mouse wheel scrolled down

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      win10
      jdk17
      javafx 21

      A DESCRIPTION OF THE PROBLEM :
      I encountered a strange bug while using the TableView component in JavaFX. To reproduce this bug, the following conditions need to be met:

      1. The horizontal scrollbar of the TableView needs to appear.
      2. The vertical scrollbar of the TableView needs to appear, but this scrollbar should be non-scrollable.
      3. When you scroll down using the mouse wheel and then click on the table, some data inside the table disappears.

      However, I monitored the `itemsProperty()` of the TableView and did not find any changes in the elements.

      Environment:

      - JDK 17
      - JavaFX 21

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. The horizontal scrollbar of the TableView needs to appear.
      2. The vertical scrollbar of the TableView needs to appear, but this scrollbar should be non-scrollable.
      3. When you scroll down using the mouse wheel and then click on the table, some data inside the table disappears.



      ---------- BEGIN SOURCE ----------
      package org.example;

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;
      import javafx.util.Callback;

      import java.util.HashMap;
      import java.util.Map;

      public class TestTableView extends Application {

          @Override
          public void start(Stage primaryStage) {

              StackPane root = new StackPane();

              TableView<Map> tableView = new TableView<>();
              int size = 10;
              for (int i = 0; i < size; i++) {
                  TableColumn<Map,String> tableColumn = new TableColumn<>(i+"");
                  int finalI = i;
                  tableColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map, String>, ObservableValue<String>>() {
                      @Override
                      public ObservableValue<String> call(TableColumn.CellDataFeatures<Map, String> mapStringCellDataFeatures) {
                          return new SimpleStringProperty(finalI+"");
                      }
                  });
                  tableView.getColumns().add(tableColumn);

              }
              for (int i = 0; i < 10; i++) {
                  Map<String,String> map = new HashMap<>();
                  tableView.getItems().add(map);
                  for (int j = 0; j < size; j++) {
                      map.put(j+"",j+"");
                  }

              }
              root.getChildren().add(tableView);
              //Adjust the height according to your screen resolution to reproduce the bug.
              Scene scene = new Scene(root, 250, 290);
              primaryStage.setScene(scene);
              primaryStage.setTitle("Popup at Screen Corner");
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }

      ---------- END SOURCE ----------

        1. after-scrolling.png
          after-scrolling.png
          12 kB
        2. before-scroll.png
          before-scroll.png
          24 kB
        3. Screenshot 2024-08-02 at 11.17.53.png
          Screenshot 2024-08-02 at 11.17.53.png
          816 kB
        4. Test.java
          2 kB

            angorya Andy Goryachev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: