There is JPanel with multiple JLabel components. I would like to change the border color of JLabel component that is clicked on. I tried this.getComponentAt(e.getX(), e.getY()).setBorder(solidBorder) , but it did not work... How could I solve this task?

I created a class that extends ArrayList and implements MouseListener. The ArrayList contains JLabel components. So, the problem is solved:)