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

Specification for the javax.swing.DefaultRowSorter.setMaxSortKeys(int max) method is not clear

XMLWordPrintable

    • b53
    • generic
    • windows_xp

      In specification for the method javax.swing.DefaultRowSorter.setMaxSortKeys(int max) is written:

      "Sets the maximum number of sort keys. The number of sort keys determines how equal values are resolved when sorting. For example, assume a table row sorter is created and setMaxSortKeys(2) is invoked on it. The user clicks the header for column 1, causing the table rows to be sorted based on the items in column 1. Next, the user clicks the header for column 2, causing the table to be sorted based on the items in column 2; if any items in column 2 are equal, then those particular rows are ordered based on the items in column 1. In this case, we say that the rows are primarily sorted on column 2, and secondarily on column 1. If the user then clicks the header for column 3, then the items are primarily sorted on column 3 and secondarily sorted on column 2. Because the maximum number of sort keys has been set to 2 with setMaxSortKeys, column 1 no longer has an effect on the order.

      The maximum number of sort keys is enforced by toggleSortOrder. You can specify more sort keys by invoking setSortKeys directly. The default value is 3. "

      Do the sentences:
      "The maximum number of sort keys is enforced by toggleSortOrder. You can specify more sort keys by invoking setSortKeys directly."
      mean that maximum number of sort keys absolutely doesn't have effect on the setSortKeys method?
      I mean, if I set sort keys like:
      keys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
      keys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));
      keys.add(new RowSorter.SortKey(2, SortOrder.DESCENDING));
      and invoke
                 rowSorter.setMaxSortKeys(2);
                 rowSorter.setSortKeys(keys);
      will the column number 2 have effect on the order? In other words, has the method setMaxSortKeys() any effect on the setSortKeys() and sorting?
      If not, it is desirable to indicate this fact in spec more clear. If yes, the same.

            svioletsunw Scott Violet (Inactive)
            ynovozhi Yulia Novozhilova (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: