开发者

Java Swing JTable sort

开发者 https://www.devze.com 2023-01-06 17:23 出处:网络
I have a JTable with column headers.When I click on a column header the data gets sorted.This is the default sort behavior.

I have a JTable with column headers. When I click on a column header the data gets sorted. This is the default sort behavior.

The thing is that I need to remember the last column the user clicked to sort. Anyone knows which listener I need to implement in order to catch the column name that user clicked for sorting on the JTable?

The code is already implemente开发者_如何学JAVAd and I'm new to Swing. I just need to add that extra functionality. So any clues will be helpful.

Thanks in advance.


You can add a MouseListener to the JtableHeader. Then you just use the columnAtPoint(...) method to determine when a column is clicked.


Use Swing-X components, there is a JXTable which is more powerful than JTable.

0

精彩评论

暂无评论...
验证码 换一张
取 消