Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir,
I had displayed the the Table in GUI window,ie., table s
retrived from Database(MSSQL-SQL SERVER).

What i want is for each column we need insert two buttons,if one
button clicked its column is arranged in ascending order and if other
button pressed its column arranged in decending order.According to its row,other rows should change.
.
These two buttons are present in every column on the top.

What method is used for the buttons which makes ascending & descending order to be inserted to every column in the JTable.

Plz suggest me.

Thanks & Regards
Pradeep
Posted

I would suggest that you do what most grids do, clcik on the heading for the column to sort it ascending then descending. The good thing about that is the action is normal.
Top actually sort the rows, have a look at these examples.[^]
 
Share this answer
 
Comments
Pradeep CBZ 4-Jan-12 2:37am    
OK thank u sir, i had gone to that link...it helped me,and sir in that two columns were there:property string and Value,in tht if i click Value its column is arranged in ascending order.But after clicking again the Value column it should arrange in the descending order,bt there it is not happening..


i want by clicking the same button both ascending & descending should happen.Sir if u got any idea about tht please share with me.


Plz help me...

Thanking u,
Pradeep
Nagy Vilmos 4-Jan-12 4:51am    
I think I may have given you an over complicated example, look at the simplest one "14.63.1. JTable Sorting in JDK6"; the link is after the code.
Pradeep CBZ 4-Jan-12 22:37pm    
Sir,
I got the solution ,after using this method setAutoCreateRowSorter(true) in main program,we can make the the column in the ascending & descending order with there alphabets & with there rows ordered automatically.
Sir,
I got the solution ,after using this method setAutoCreateRowSorter(true) in main program,we can make the the column in the ascending & descending order with there alphabets & with there rows ordered automatically.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900