Fin de tout
This commit is contained in:
67
DEV2.1/TP09/04_Multiple/GestionSouris.java
Normal file
67
DEV2.1/TP09/04_Multiple/GestionSouris.java
Normal file
@@ -0,0 +1,67 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user