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

TableView item becomes unselectable

    XMLWordPrintable

Details

    • x86_64
    • generic

    Description

      A DESCRIPTION OF THE PROBLEM :
      When I add several items to TableView so that they do not fit into visible table area without scrolling, select the last one, scroll to the top and reverse the item list, the first item strangely reacts on mouse clicks and becomes unselectable.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the attached example code
      2. Assert the last item is not on the screen (if it is displayed, increase item count)
      3. Scroll the list down
      4. Select the last item (left-click **on the text** in the column)
      5. Scroll the list to the top (now selection is not visible)
      6. Press the Reverse button
      7. Click on the new first item several times with the left mouse button

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The table selection still works as expected, allowing to select arbitrary item.
      ACTUAL -
      The first item visually cannot be selected. When I click on it, the last item becomes visually selected instead.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class JavaFxTableBug extends Application {
          private TableView<SimpleStringProperty> table = new TableView<>();
          private Button reverseButton = new Button("Reverse");

          @Override
          public void start(Stage primaryStage) throws Exception {
              table.setMaxHeight(100);

              TableColumn<SimpleStringProperty, String> column = new TableColumn<>();
              column.setCellValueFactory(x -> x.getValue());
              table.getColumns().add(column);

              for (int i = 0; i < 5; ++i) {
                  table.getItems().add(new SimpleStringProperty("Click on the text"));
              }

              reverseButton.setOnAction(unused -> {
                  ObservableList<SimpleStringProperty> tmp = FXCollections.observableArrayList(table.getItems());
                  FXCollections.reverse(tmp);
                  table.getItems().setAll(tmp);
              });

              primaryStage.setScene(new Scene(
                      new VBox(reverseButton, table)
              ));
              primaryStage.show();
          }

          public static void main(String[] args) {
              Application.launch(args);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      In some cases it may be appropriate to replace
      table.getItems().setAll(tmp);
      with
      table.setItems(tmp);
      Then this problems goes away.

      FREQUENCY : always


      Attachments

        Activity

          People

            kpk Karthik P K
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: