import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Playlist extends JPanel implements MouseListener { private JLabel prevSelection; private JLabel prevHover; public void mouseClicked(MouseEvent evenement) { JLabel raiser = evenement.getComponent(); raiser.setBackground(new Color(0, 150, 255)); if (prevSelection != null) { prevSelection.setBackground(new Color(255, 255, 255)); } } public void mouseEntered(MouseEvent evenement) { } public void mouseExited(MouseEvent evenement) { } public void mousePressed(MouseEvent evenement) {} public void mouseReleased(MouseEvent evenement) {} @Override public void paintComponent(Graphics brush) { } public Playlist() { super(); } public void add(String title) { JLabel l = new JLabel(title); l.addMouseListener(this); l.setOpaque(true); this.add(l); } }