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

Wrong behaviour or documentation for ListChangeListener.Change

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • None
    • fx2.0
    • javafx
    • Windows 7, JDK7, JavaFX b40

    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

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported: