• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JTable set up default auto-sorted column

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear community,

let me ask you a question: how can I defined column to be auto-sorted?
The problem is the following: creating JTable with some columns, set auto sort to true and some other cosmetic stuff.

I'm perfectly happy with the result on the screen with the only exception - each time this window appear I need to click on the first column to make logs display sorted by they appearance - how can I make JTable window appear with the column #0 sorted by default, with no writing my personal sorter?

Googled, but didn't find any tricks on this.

Thanks in advance,
Regards,
/Alexander.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> how can I make JTable window appear with the column #0 sorted by default

table.getRowSorter().toggleSortOrder(0);
 
Alexander Pupkin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Dunn:
> how can I make JTable window appear with the column #0 sorted by default

table.getRowSorter().toggleSortOrder(0);



As easy and great as expected - thanks a lot!

Last sub-question: how can I reverse order for this column? Didn't find right method at the RowSorter instance...
 
Alexander Pupkin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Last sub-question: how can I reverse order for this column? Didn't find right method at the RowSorter instance...[/QB]



My apologize - it's the same method call =)

Thanks a lot!
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic