I have 20 JLabels
and all of them have to change their background color when mouse enters and change back to original color when mouse outs.
Do I have to individually bind 2 Event-listeners of MouseEntered
and MouseExited
with all JLabel
s separately, or is there any work around so I can make just 2 events kind of monitoring all JLabel
s?
Like in the image below: there are about 6 JLabels
and I want each one to change its background color whenever the mouse enters the scene and change back to original color when the mouse outs.
So, do I have to individually set event listeners on all JLabels
, or there can be a single event listener for all JLabels
?