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

TableView: multiple selection state broken after replace of item


    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 8u131, 9
    • Fix Version/s: tbd
    • Component/s: javafx
    • Environment:



      To reproduce: run the example below and

      - select multiple rows
      - click button to replace an item in the table's item list with a new one
      - expected: selection unchanged
      - actual: selection cleared except the lead selection

      Astonished (by a question on SO - https://stackoverflow.com/q/45915478/203657), I thought the rough edges around data modification and selection had been fixed... add/remove looks okay, just the set is still weird

      The example:

      package test.selection;
      import java.util.Locale;
      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

       * TableView: multiple selection lost on set item.
      public class TableViewMultipleSelectionLostOnSet extends Application {

          private int counter;

          private Parent getContent() {
              TableView<Locale> table = new TableView<>(FXCollections.observableArrayList(
              TableColumn<Locale, String> countryCode = new TableColumn<>("CountryCode");
              countryCode.setCellValueFactory(new PropertyValueFactory<>("country"));
              TableColumn<Locale, String> language = new TableColumn<>("Language");
              language.setCellValueFactory(new PropertyValueFactory<>("language"));
              TableColumn<Locale, String> variant = new TableColumn<>("Variant");
              variant.setCellValueFactory(new PropertyValueFactory<>("variant"));
              table.getColumns().addAll(countryCode, language, variant);
              Button set = new Button("Set");
              set.setOnAction(e -> table.getItems().set(3, new Locale("dummy " + counter++)));
              HBox buttons = new HBox(10, set);
              BorderPane pane = new BorderPane(table);
              return pane;

          public void start(Stage primaryStage) throws Exception {
              primaryStage.setScene(new Scene(getContent(), 800, 400));

          public static void main(String[] args) {





            • Assignee:
              aghaisas Ajit Ghaisas
              fastegal Jeanette Winzenburg
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: