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

[SortedList] should provide a sort() method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u20
    • javafx
    • Windows 7 64bit, JDK 8u20 Build b23 64bit

      If the sorting of a SortedList depends on other data then the source list there is no nice way to sort the SortedList again if the other data has been changed.

      A (not very nice) workaround is to set a new Comparator for the SortedList every time the other data has been changed:

      IntegerProperty counter = new SimpleIntegerProperty();
      SortedList<String> sortedList = new SortedList<>(mySourceList);
      sortedList.setComparator(new Comparator<String>() {
      @Override
      public int compare(String o1, String o2) {
      int result = 0;
      // Compare based on counter
      return result;
      }
      });
      myListView.setItems(sortedList.sorted());

      counter.addListener(o -> sortedList.setComparator(new Comparator<String>() {
      @Override
      public int compare(String o1, String o2) {
      int result = 0;
      // Compare based on counter
      return result;
      }
      }));

            Unassigned Unassigned
            aliebelt Andreas Liebelt
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Imported: