how can I listen for clicks on my columns? I have sorting methods and they work, but how can I listen for clicks on a certain column header? It's probably something obvious I missed when reading through Sun's documentation?
posted 10 years ago
Ok, figured it out.
basically I did this: made a global variable private JTableHeader header; implemented MouseListener. then in my main method header = tablename.getTableHeader(); header.addMouseListener(this); then in mouseClicked method I just did this: if (e.getX()<header.getHeaderRect(int columnNumber).getX()) execute code... basically to reg a click on the first column I used columnNumber 1 since that is basically the far most right point of column 0. Probably it would be best to go a reverse order instead... so: