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

Problems Multiple-Selecting Rows in TableView



    • Bug
    • Status: Closed
    • P3
    • Resolution: Fixed
    • 8
    • 8
    • javafx
    • build 92, running on Windows 8


      Run the following sample code:

      public class TableSelectionBug extends Application {
         public static void main(String[] args) {
         public void start(Stage primaryStage) {
             primaryStage.setTitle("Table Selection Bug Demo");
             TableView<String> table = new TableView<>();
             TableColumn<String, String> column1 = new TableColumn<>("Column 1");
             column1.setCellValueFactory( null );
             column1.setPrefWidth( 100 );
             TableColumn<String, String> column2 = new TableColumn<>("Column 2");
             column2.setPrefWidth( 100 );
             table.getColumns().setAll( column1, column2 );
             table.getItems().addAll( "1", "2", "3", "4", "5", "6", "7" );
             table.getSelectionModel().setSelectionMode( SelectionMode.MULTIPLE );

             StackPane root = new StackPane();
             primaryStage.setScene(new Scene(root, 600, 250));

      This creates a TableView with 7 rows and 2 columns, plus a few "empty" rows and columns. You'll have to use your imagination a bit here, since for brevity my sample doesn't have cell value factories, so you can't actually see any values in the 7 populated rows and 2 columns.

      The bug here involves selecting multiple rows. First, click on (row 1, col 1), then hold down shift and click on (row 5, col 1). 5 rows become selected, no problem. Now, continue to hold down shift and click on (row 1, col 1) again. What?! Only rows 2 and 4 become deselected.

      A second problem here is also related to selecting multiple rows. First click on (row 1, col 3) -- that's an empty "filler" cell, since there is no column 3 in this table. The first row is selected, as you'd expect. Now hold down shift and click on (row 5, col 3). Strangely, only row 5 is now selected--it behaves like you weren't holding shift down when you clicked!

      In other words, shift-selecting doesn't work if you click on cells in that third "filler" column, even though regular selection and control-selecting works fine for those cells.




            jgiles Jonathan Giles
            cbanackjfx Cory Banack (Inactive)
            0 Vote for this issue
            3 Start watching this issue