ListBox hover?

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?

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?

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).

1 Like

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