Forums Register Login

Sorting the rows in a JTable

+Pie Number of slices to send: Send
Hai friends,
I want the code for sorting entire records in a Jtable.i know how to sort a perticular column.But i need to sort entire records in a JTAble.If any one knows the solution please help me..Waiting for a reply...
Regards,
Srinivas.
+Pie Number of slices to send: Send
check for the edited rows & whenever you encounter an unedited row or a blank row, stop incrementing the counter. For that use getRowCount() method within the for loop.
i.e for(i-0;i<=TableName.getRowCount();i++){

write the code here to find the unedited row
}
+Pie Number of slices to send: Send
Howdy,
Check out the "How to Use Tables" tutorial in the main Java Tutorial (you can find it by going to the Java documentation and then to JTable -- the link should be up near the top). Specifically, there's a whole section down near the bottom which deals with TableModels and how to use them. It also comes with code that you can steal wholesale and use, if you don't care about how it works. The basic idea is that you stick an intermediary table model between the table and your real table model. The intermediary provides a mapping between the real table data and the order it is to be displayed on the screen. Thus, to sort the table, you just reorder the mapping rather than move around data in the underlying table model.
I'm not explaining this terribly well, but the tutorial is pretty good at explaining what it's doing.
-- Ed
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 945 times.
Similar Threads
How to sort a ResultSet
Core JSF datatable pagination and sorting
Quicksort in java
problem with merging records from two tables while sorting
Suggestion Needed on tuning the performance.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:42:26.