58 lines
1.3 KiB
Java
58 lines
1.3 KiB
Java
import java.awt.event.*;
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class GestionSouris implements MouseListener {
|
|
|
|
private JLabel2 titre;
|
|
private Fenetre fenetre;
|
|
private JLabel2 actif;
|
|
private boolean actuelEstActif;
|
|
|
|
public GestionSouris(JLabel2 titre, Fenetre fenetre) {
|
|
this.titre = titre;
|
|
this.fenetre = fenetre;
|
|
}
|
|
|
|
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){
|
|
if (!this.actuelEstActif) {
|
|
this.titre.setOpaque(true);
|
|
this.titre.setBackground(null);
|
|
this.titre.repaint();
|
|
}
|
|
else {
|
|
this.titre.setBackground(Color.LIGHT_GRAY);
|
|
this.titre.repaint();
|
|
}
|
|
}
|
|
|
|
public void mousePressed(MouseEvent evenement){
|
|
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);
|
|
}
|
|
|
|
public void mouseReleased(MouseEvent evenement){
|
|
}
|
|
|
|
public void setActuelEstActif(boolean n) {
|
|
this.actuelEstActif = n;
|
|
}
|
|
} |