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

More than one table cell are in edit state

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

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


      ADDITIONAL OS VERSION INFORMATION :
      Linux DEKA01-B04014-PC0004 3.13.0-105-generic #152-Ubuntu SMP Fri Dec 2 15:37:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The reuse of cells in TableView seems to result in cells having the edit state when they should not.

      There is also a related old question on StackOverflow: http://stackoverflow.com/questions/40561979/javafx-table-view-cell-reuse

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      My programm consists of an editable TableView with 60 rows. On program start 17 are visible without scrolling. I put a cell on the first row in edit state by clicking on it. While that cell is in edit state, I scroll down. In regular intervalls the cells further down are in edit state, too.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Only one cell should be in edit state.
      ACTUAL -
      About every 20th cell is is in edit mode.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.List;
      import java.util.stream.Collectors;
      import java.util.stream.IntStream;

      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.collections.FXCollections;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.TextFieldTableCell;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class TableViewMain extends Application {
          private TableView<Person> table = new TableView<>();
          public static void main(final String[] args) {
              launch(args);
          }
          
          private static class Person {
              StringProperty age = new SimpleStringProperty(this, "age");
              
              Person(final String age) {
                  this.age.set(age);
              }
              
              StringProperty ageProperty() {
                  return age;
              }
              
          }
       
          @Override
          public void start(final Stage stage) {
              final Scene scene = new Scene(new Group());
              stage.setTitle("Table View Sample");
              stage.setWidth(300);
              stage.setHeight(500);
        
              table.setEditable(true);
       
              final TableColumn<Person, String> column = new TableColumn<Person, String>("Age");
              column.setCellValueFactory(data -> data.getValue().ageProperty());
              column.setCellFactory(TextFieldTableCell.forTableColumn());
              
              final List<Person> data = IntStream.range(0, 60).mapToObj(i -> new Person(Integer.toString(i))).collect(Collectors.toList());
              table.setItems(FXCollections.observableList(data));
       
              table.getColumns().add(column);
              
              final BorderPane pane = new BorderPane();
              pane.setCenter(table);
              scene.setRoot(pane);
        
              stage.setScene(scene);
              stage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      There is aworkaround mentioned on stackoverflow that I have not tried: http://stackoverflow.com/questions/40561979/javafx-table-view-cell-reuse

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: