Results 1 to 6 of 6
  1. #1
    new2java2009 is offline Member
    Join Date
    Aug 2009
    Posts
    60
    Rep Power
    0

    Default SortOrder vs SortKey

    The following 'if' statement has a mismatched types. Can somebody tell me how to fix it? Thanks!

    if (this.indicationTable.getRowSorter().getSortKeys() .get(i) == SortOrder.ASCENDING)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Well, JTable#getRowSorter returns a RowSorter object, and getSortKeys() returns a java.util.List, and get(i) will get whatever object is held by the list in the ith position.

    On the other hand SortOrder is an enum so of course these will be completely different and cannot be compared the way you are trying. I have to ask what are you trying to do. Perhaps you should tell enough details of your problem so that it can be answerable.

  3. #3
    new2java2009 is offline Member
    Join Date
    Aug 2009
    Posts
    60
    Rep Power
    0

    Default

    Well, I want to see how the column is sorted, kind of like:

    if column(index) is sorted Acending then
    do something
    else
    do something else.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I am not familiar with this sort of thing, but I am familiar with the Java API, and by searching the API, I see that the SortOrder entry states "See Also: RowSorter", and the RowSorter API has a nested class called RowSorter.SortKey that has a method getSortOrder() which returns a SortOrder object. Perhaps this is what you want:

    Java Code:
    if (indicationTable.getRowSorter().getSortKeys().get(i).getSortOrder == SortOrder.ASCENDING) {
      //....
    }
    Best of luck.
    Last edited by Fubarable; 04-12-2010 at 11:12 PM.

  5. #5
    new2java2009 is offline Member
    Join Date
    Aug 2009
    Posts
    60
    Rep Power
    0

    Default

    Yes! This works well! Thank you so much!

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. javax.swing.RowSorter.SortKey
    By new2java2009 in forum New To Java
    Replies: 1
    Last Post: 04-11-2010, 03:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •