Files
DEV/DEV2.1/TP09/02_Playlist/GestionSouris.java

58 lines
1.3 KiB
Java
Raw Normal View History

2025-03-11 10:02:42 +01:00
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class GestionSouris implements MouseListener {
2025-03-12 17:10:44 +01:00
private JLabel2 titre;
private Fenetre fenetre;
private JLabel2 actif;
private boolean actuelEstActif;
2025-03-11 10:02:42 +01:00
2025-03-12 17:10:44 +01:00
public GestionSouris(JLabel2 titre, Fenetre fenetre) {
2025-03-11 10:02:42 +01:00
this.titre = titre;
2025-03-12 17:10:44 +01:00
this.fenetre = fenetre;
2025-03-11 10:02:42 +01:00
}
public void mouseClicked(MouseEvent evenement) {
}
public void mouseEntered(MouseEvent evenement){
this.titre.setOpaque(true);
this.titre.setBackground(Color.CYAN);
this.titre.repaint();
}
public void mouseExited(MouseEvent evenement){
2025-03-12 17:10:44 +01:00
if (!this.actuelEstActif) {
this.titre.setOpaque(true);
this.titre.setBackground(null);
this.titre.repaint();
}
else {
this.titre.setBackground(Color.LIGHT_GRAY);
this.titre.repaint();
}
2025-03-11 10:02:42 +01:00
}
public void mousePressed(MouseEvent evenement){
2025-03-12 17:10:44 +01:00
this.titre.setBackground(Color.LIGHT_GRAY);
this.actuelEstActif = true;
this.titre.repaint();
if (this.fenetre.getEstActif()) {
this.fenetre.getActif().setBackground(null);
this.fenetre.getActif().getGestionnaireSouris().setActuelEstActif(false);
this.fenetre.getActif().repaint();
}
this.fenetre.setEstActif(true);
this.fenetre.setActif(this.titre);
}
2025-03-11 10:02:42 +01:00
public void mouseReleased(MouseEvent evenement){
}
2025-03-12 17:10:44 +01:00
public void setActuelEstActif(boolean n) {
this.actuelEstActif = n;
}
2025-03-11 10:02:42 +01:00
}