I used Philip Milne's TableSorter class. The code posted for this seems to
have been updated since I used it, but I think the principle is the same:
the TableSorter sits in between the Table and its Data Model. I manage to
customise the previous version to sort differently, and to respond
differently to mouse clicks (by extending its listMouseAdapter class). There
are lots of other useful JTable examples at the same site:-
http://www2.gol.com/users/tame/swing/examples/JTableExamples5.html
> Regards,
>
> Mark Berry
>
> mailto:[EMAIL PROTECTED]
> TEL: +44 (0) 115 943 2651 (or 780 2651 internally)
>
> "Internet communications are not secure and therefore Siemens
> Communications Limited does not accept legal responsibility for the
> contents of this message. Any views or opinions presented are solely
> those of the author and do not necessarily represent those of Siemens
> Communications Limited unless otherwise specifically stated".
>
> � Siemens Communications Ltd
>
>
-----Original Message-----
From: Greg Munt [mailto:[EMAIL PROTECTED]]
Sent: 13 September 2001 13:22
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Clickable headers for JTable?
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
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing