Fin de tout
This commit is contained in:
BIN
DEV2.1/TP09/04_Multiple/Fenetre.class
Normal file
BIN
DEV2.1/TP09/04_Multiple/Fenetre.class
Normal file
Binary file not shown.
58
DEV2.1/TP09/04_Multiple/Fenetre.java
Normal file
58
DEV2.1/TP09/04_Multiple/Fenetre.java
Normal file
@@ -0,0 +1,58 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
private JLabel2 actif;
|
||||
private boolean estActif;
|
||||
|
||||
public Fenetre() {
|
||||
this.estActif = false;
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(14, 1));
|
||||
|
||||
JLabel2[] chromakopia = {
|
||||
new JLabel2("St. Chroma"),
|
||||
new JLabel2("Rah Tah Tah"),
|
||||
new JLabel2("Noid"),
|
||||
new JLabel2("Darling, I"),
|
||||
new JLabel2("Hey Jane"),
|
||||
new JLabel2("I Killed You"),
|
||||
new JLabel2("Judge Judy"),
|
||||
new JLabel2("Sticky"),
|
||||
new JLabel2("Take Your Mask Off"),
|
||||
new JLabel2("Tomorrow"),
|
||||
new JLabel2("Thought I Was Dead"),
|
||||
new JLabel2("Like Him"),
|
||||
new JLabel2("Balloon"),
|
||||
new JLabel2("I Hope You Find Your Way Home")
|
||||
};
|
||||
|
||||
for (JLabel2 titre : chromakopia) {
|
||||
GestionSouris gestion = new GestionSouris(titre, this);
|
||||
titre.addMouseListener(gestion);
|
||||
titre.setGestionnaireSouris(gestion);
|
||||
this.add(titre);
|
||||
}
|
||||
|
||||
this.pack();
|
||||
}
|
||||
|
||||
public boolean getEstActif() {
|
||||
return this.estActif;
|
||||
}
|
||||
|
||||
public void setEstActif(boolean n) {
|
||||
this.estActif = n;
|
||||
}
|
||||
|
||||
public void setActif(JLabel2 n) {
|
||||
this.actif = n;
|
||||
}
|
||||
|
||||
public JLabel2 getActif() {
|
||||
return this.actif;
|
||||
}
|
||||
|
||||
}
|
BIN
DEV2.1/TP09/04_Multiple/GestionSouris.class
Normal file
BIN
DEV2.1/TP09/04_Multiple/GestionSouris.class
Normal file
Binary file not shown.
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;
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/04_Multiple/JLabel2.class
Normal file
BIN
DEV2.1/TP09/04_Multiple/JLabel2.class
Normal file
Binary file not shown.
19
DEV2.1/TP09/04_Multiple/JLabel2.java
Normal file
19
DEV2.1/TP09/04_Multiple/JLabel2.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class JLabel2 extends JLabel {
|
||||
private GestionSouris gestionnaireSouris;
|
||||
|
||||
public JLabel2(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public void setGestionnaireSouris(GestionSouris n) {
|
||||
this.gestionnaireSouris = n;
|
||||
}
|
||||
|
||||
public GestionSouris getGestionnaireSouris() {
|
||||
return this.gestionnaireSouris;
|
||||
}
|
||||
}
|
BIN
DEV2.1/TP09/04_Multiple/Main.class
Normal file
BIN
DEV2.1/TP09/04_Multiple/Main.class
Normal file
Binary file not shown.
6
DEV2.1/TP09/04_Multiple/Main.java
Normal file
6
DEV2.1/TP09/04_Multiple/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user