I’m writing a program to do some statistical analysis on data imported from a csv file or database. I can get the data loaded into a jTable and displayed but I’m struggling with the next step.
I would like to be able to click on a column heading and have the summary stats for the contents of the column displayed in a label in a panel to the side of the jTable (see image).

Can anyone suggest methods to look at or example code for similar projects? Any help would be appreciated.
EDIT:
I’m doing this in netbeans. Usually in netbeans I just click on the component in design mode and add a listener by right clicking and then filling in the code on the source tab. However, I’m not sure how to add a listener to a table or header when it’s not visible in the design tab.
So, the problem has two parts:-
The event handler to execute when the column is selected.
The code to get the summary.
For the first one (event handler), you could refer to @Jeffrey’s answer. For the summary part you could write a method like this:
Call this method from inside the event handler like this:
The object array could be used to compute the summary you require, like finding the range, Standard deviation, etc. Those should be trivial. Remember to typecast the Object array in the calling method.