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

TableView: dragged column gets moved to a wrong position when some columns are not visible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 9
    • 8u92
    • javafx
    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]
      Windows 7 x64

      A DESCRIPTION OF THE PROBLEM :
      The minimalistic test case is attached.
      When I drag column "Col 00" (hold mouse on column header) and drop it between "Col 14" and "Col 16" it gets actually moved to be between "Col 10" and "Col 12", which is unexpected.
      The problem is only reproducible when there are not visible columns.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Start the test case
      2) drag column "Col 00" (hold mouse on column header)
      3) drop between "Col 14" and "Col 16" (release mouse between the columns)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "Col 00" gets moved between "Col 14" and "Col 16"
      ACTUAL -
      "Col 00" gets moved between "Col 10" and "Col 12"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package de.lexcom.tableview;

      import java.util.ArrayList;
      import java.util.HashMap;
      import java.util.List;
      import java.util.Map;

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.collections.FXCollections;
      import javafx.scene.Scene;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.stage.Stage;

      public class FXTableViewExample6 extends Application {
          public static void main(String [] args) {
              Application.launch(args);
          }

          private TableView<Integer> table;
          private final static int NUM_COLUMNS = 20;

          @Override
          public void start(Stage primaryStage) {
              table = new TableView<>();
              
              final Map<Integer, List<StringProperty>> data = new HashMap<>();
              for (int i=0; i<20; i++) {
                  List<StringProperty> row = new ArrayList<>();
                  for (int j=0; j<NUM_COLUMNS; j++) {
                      row.add(new SimpleStringProperty(String.format("%02d-%02d", i, j)));
                  }
                  data.put(i, row);
              }
              table.setItems(FXCollections.observableArrayList(data.keySet()));

              for (int j=0; j<NUM_COLUMNS; j++) {
                  TableColumn<Integer, String> col = new TableColumn<>(String.format("Col %02d", j));
                  final int _j = j;
                  col.setCellValueFactory(feat -> data.get(feat.getValue()).get(_j));
                  col.setVisible((j%2) == 0);
                  table.getColumns().add(col);
              }

              table.setEditable(false);
              table.setTableMenuButtonVisible(true);
              
              Scene scene = new Scene(table, 500, 475);
              primaryStage.setScene(scene);
              primaryStage.show();
          }
      }

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

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: