TableView - listening to events on table headers

Pedro Duque Vieira pedro.duquevieira at gmail.com
Mon Oct 22 16:42:00 PDT 2012


Hi,

In my app I have to listen to mouse events on table headers, I've tried to
come up with a good solution to this but haven't found any. Posting in the
JavaFX OTN forums also did not bring any better solution.
As it is the only solution I see is replacing the headers via setGraphic
method of TableColumn and attaching listeners to what I pass in to the
setGraphic, even though I will end up replacing the TableColumn header with
the same type of node as was previously present, so I end up calling
setGraphic only for the sake of being able to attach listeners. This looks
ugly.

Is there any better solution for this?

My use case is:
1- user mouse clicks the a table header to select a column
2- column gets selected.
3- Selected column is visually highlighted.

Thanks,


-- 
Pedro Duque Vieira


More information about the openjfx-dev mailing list