Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sort JTable Data on Column Header Click

 
Hewa Naimanage Sumedha Amalka
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Im trying to sort a jTable on column click, but when I insert the mouse click event; my panel is not updating with sorted table.

I used sorting algo in a separated class and code is working properly if I remove the header click event and uncomment other stuffs in bottom



thanks in advance !
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> my panel is not updating with sorted table.

actually, it is - you can't see it because 'panel' is a FlowLayout.
run the program, click a header, now drag the frame real wide (so there's enough space to show the 2 tables)

you can either
change 'panel' to a more suitable LayoutManager, or better
change the model of the visible table (instead of creating another table)
 
Hewa Naimanage Sumedha Amalka
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked... thanks Michael...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic