2024-03-18 13:54:22 +01:00
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.*;
|
|
|
|
|
|
2024-03-18 14:28:35 +01:00
|
|
|
public class Playlist extends JFrame implements MouseListener {
|
|
|
|
|
|
2024-03-18 13:54:22 +01:00
|
|
|
@Override
|
2024-03-18 14:28:35 +01:00
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
this.setBackground(Color.LIGHT_GRAY);
|
2024-03-18 13:54:22 +01:00
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 14:28:35 +01:00
|
|
|
@Override
|
|
|
|
|
public void mouseEntered(MouseEvent e) {
|
|
|
|
|
this.setBackground(Color.CYAN);
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseExited(MouseEvent e) {
|
|
|
|
|
this.setBackground(Color.WHITE);
|
|
|
|
|
repaint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Les méthodes suivantes ne sont pas utilisées mais doivent être implémentées en raison de l'interface MouseListener
|
|
|
|
|
@Override
|
|
|
|
|
public void mousePressed(MouseEvent e) {}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void mouseReleased(MouseEvent e) {}
|
|
|
|
|
|
|
|
|
|
public Playlist() {
|
|
|
|
|
super("Playlist");
|
|
|
|
|
setSize(300, 200);
|
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
setLayout(new GridLayout(9, 1));
|
2024-03-18 13:54:22 +01:00
|
|
|
|
|
|
|
|
JLabel mus1 = new JLabel("Speak To Me/Breathe");
|
|
|
|
|
JLabel mus2 = new JLabel("On The Run");
|
|
|
|
|
JLabel mus3 = new JLabel("Time");
|
|
|
|
|
JLabel mus4 = new JLabel("The Great Gig in The Sky");
|
|
|
|
|
JLabel mus5 = new JLabel("Money");
|
|
|
|
|
JLabel mus6 = new JLabel("Us And Them");
|
|
|
|
|
JLabel mus7 = new JLabel("Any Colour You Like");
|
|
|
|
|
JLabel mus8 = new JLabel("Brain Damage");
|
|
|
|
|
JLabel mus9 = new JLabel("Eclipse");
|
|
|
|
|
|
2024-03-18 14:28:35 +01:00
|
|
|
JLabel[] tab = {mus1, mus2, mus3, mus4, mus5, mus6, mus7, mus8, mus9};
|
2024-03-18 13:54:22 +01:00
|
|
|
|
2024-03-18 14:28:35 +01:00
|
|
|
for (JLabel label : tab) {
|
2024-03-18 14:35:20 +01:00
|
|
|
label.setOpaque(true);
|
2024-03-18 14:28:35 +01:00
|
|
|
label.addMouseListener(this);
|
|
|
|
|
add(label);
|
2024-03-18 13:54:22 +01:00
|
|
|
}
|
|
|
|
|
|
2024-03-18 14:28:35 +01:00
|
|
|
setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Playlist play = new Playlist();
|
2024-03-18 13:54:22 +01:00
|
|
|
}
|
|
|
|
|
}
|