aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Sort JTable Data on Column Header Click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Sort JTable Data on Column Header Click" Watch "Sort JTable Data on Column Header Click" New topic
Author

Sort JTable Data on Column Header Click

Hewa Naimanage Sumedha Amalka
Greenhorn

Joined: Oct 31, 2006
Posts: 19
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 !


SCJP 1.4 71%, SCWCD 1.5 84%, SCBCD 90%, SCMAD 98%
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Oct 31, 2006
Posts: 19
It worked... thanks Michael...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sort JTable Data on Column Header Click
 
Similar Threads
JTable Columns
JTable ........
JTable with RadioButton Headers
How to change Jtable Total Rows in runtime ?
add custom Jtable to GUI Builder How?