File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTable header click event ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable header click event ?" Watch "JTable header click event ?" New topic

JTable header click event ?

Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
Hi Ranchers ,

I wonder is there a way to detect the user clicking on the header of the table so i can execute some code if he did this ?

Thanks ,

Rob Spoor

Joined: Oct 27, 2005
Posts: 19896

JTableHeader can have a MouseListener added just like almost any other control.

How To Ask Questions How To Answer Questions
Hesham Gneady
Ranch Hand

Joined: Feb 26, 2007
Posts: 66
Thanks Rob ... actually what i was trying to do is do some action after i click on any column header to sort the table.

I thought after the mouseReleased() event for the JTableHeader click the table should have been sorted & i can do the action i want, but i found that the sorting happens after that event.

So is there a way i can detect the table sorting is finished ?

I agree. Here's the link:
subject: JTable header click event ?