File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Sort JTable Data on Column Header Click
 
Similar Threads
JTable ........
add custom Jtable to GUI Builder How?
JTable with RadioButton Headers
How to change Jtable Total Rows in runtime ?
JTable Columns