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

[TableView] Selecting a single item after having multiple items selected in a TableView can cause one Change where the newly selected item is both removed and added.



    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 8u20
    • 8u40
    • javafx
    • Windows 8.1 (64bit), JDK 8u20-b15 (64bit)


      This confused me when manually tracking changes to a table's selectedItems via a ListChangeListener. Steps to reproduce:

      1. Run the below example.
      2. CTRL select the second item in the table so both items are selected.
      3. Select _just_ the second item in the table.


      You'll get the following output:

      --- initial selection on program start ---
      Change event...
        Added: name one

      --- caused by additionally selecting the second item ---
      Change event...
        Added: name two

      --- caused by selecting _just_ the second item ---
      Change event...
        Removed: name one
        Removed: name two
        Added: name two

      I use logic similar to the processListChange method of my example to add and remove items from another list. Since the "name two" item is removed and added at the same time, I need to make sure I check for that case rather than being able to replay the adds / removes to my other list.

      Put another way, the order of handling the added items and removed items for the Change becomes important; the removed items need to be handled first or there's no way to tell if an item was already in the manually managed list or if it was just added as part of the Change.

      If an item is both added and removed, should it actually be included in the Change? If it has to be included, would it make more sense to have it split into two separate Changes where it's removed in the first and added in the second?




            jgiles Jonathan Giles
            rjaebjfx Ryan Jaeb (Inactive)
            0 Vote for this issue
            4 Start watching this issue