67 lines
1.5 KiB
Java
67 lines
1.5 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;
|
||
|
if (!evenement.isControlDown()) {
|
||
|
System.out.println("Ctrl not Pressed");
|
||
|
}
|
||
|
else {
|
||
|
System.out.println("Ctrl Pressed");
|
||
|
}
|
||
|
this.titre.repaint();
|
||
|
|
||
|
if (this.fenetre.getEstActif() && !evenement.isControlDown()) {
|
||
|
this.fenetre.getActif().setBackground(null);
|
||
|
this.fenetre.getActif().getGestionnaireSouris().setActuelEstActif(false);
|
||
|
this.fenetre.getActif().repaint();
|
||
|
}
|
||
|
|
||
|
if (!evenement.isControlDown()) {
|
||
|
this.fenetre.setEstActif(true);
|
||
|
this.fenetre.setActif(this.titre);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void mouseReleased(MouseEvent evenement){
|
||
|
}
|
||
|
|
||
|
public void setActuelEstActif(boolean n) {
|
||
|
this.actuelEstActif = n;
|
||
|
}
|
||
|
}
|