The way I did it was to put a mouse listener on the table header, get the
Point from that, and use JTableHeader.columnAtPoint(Point) and
JTableHeader.getHeaderRect(TableColumn).

I have a pressedColumn field which is used by the renderer to
programmatically press or release a JButton within itself.

I have successfully implemented both sorting and filtering of data. I have a
clickable table header for sorting, and a button within the header which
(when pressed) reveals a popup menu used to select the data to filter on.

-----Original Message-----
From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Thursday, September 13, 2001 01:01
Subject: Clickable headers for JTable?


>
>
>
>
>I would like to set up a JTable with clickable headers.  (The goal is
>to implement sorting by the contents of the clicked-upon header's
>column.)
>
>Is there a way to do this?
>
>I tried the naive approach of sticking a raw JButton in the header,
>but this fails, not surprisingly.  Is there a way to stick a
>functioning JButton (maybe within some other Swing container) in a
>header field?
>
>Thanks!
>
>KJ
>
>_______________________________________________
>Swing mailing list
>[EMAIL PROTECTED]
>http://eos.dk/mailman/listinfo/swing

_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to