ListBox hover?


#1

Is there any way to enable hovering for the ListBox component? I would like to highlight (not select!) the current row the mouse is hovering over, so the GUI seems more responsive and modern.

Is there maybe a workaround via mouseMove / getRowForPosition and paintRow?


#2

It seems the ListBox doesn’t receive mouseMove reliably? I put a simple DBG (“hover”); in there and it only gets called when entered, but not when actually moved!

Is this intentional?


#3

I believe this may happen because the ListBox creates a child Component for each of its rows, hence the mouseMove events are intercepted by those Components and never reach the ListBox beneath.

If that’s the case, the easiest solution I see is to register a MouseListener for the ListBox that also receives events for nested Components (that behavior is specified by one of the arguments of addMouseListener(), don’t remember which).


#4

Just tried that. Works like a charm. I wondered why the hoverSelector thingy did it that way…