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

Wrong behaviour or documentation for ListChangeListener.Change

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      Windows 7, JDK7, JavaFX b40

    • Subcomponent:

      Description

      The documentation for ListChangeListener.Change suggest the following code:
      {code}
      ObservableList<Item> theList = ...;
       {
           theList.addListener(new ListChangeListener<Item>() {
               public void onChanged(Change<Item> c) {
                   while (c.next()) {
                       for (Item remitem : c.getRemoved()) {
                           remitem.remove(Outer.this);
                       }
                       for (Item additem : c.getAddedSubList()) {
                           additem.add(Outer.this);
                       }
                   }
               }
           });
       }
      {code}
      But this will not work because c.next() returns false if there was only one change.
      See attached example.

        Attachments

          Activity

            People

            • Assignee:
              mheinrichs Michael Heinrichs (Inactive)
              Reporter:
              dpausjfx Dr. Michael Paus (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: