update
This commit is contained in:
27
DEV.3.1/TP/TP2/Galerie.1/Controlleur.java
Normal file
27
DEV.3.1/TP/TP2/Galerie.1/Controlleur.java
Normal file
@@ -0,0 +1,27 @@
|
||||
public class Controlleur {
|
||||
|
||||
private int numFenetre = 0;
|
||||
private GFenetre gfenetre;
|
||||
|
||||
public Controlleur() {
|
||||
this.gfenetre = gfenetre
|
||||
}
|
||||
|
||||
public void change(int numFenetre) {
|
||||
this.numFenetre = numFenetre;
|
||||
frame.getContentPane().removeAll();
|
||||
|
||||
if(this.numFenetre == 0) {
|
||||
if(this.getImage() == )
|
||||
this.image1.setHorizontalAlignment(JLabel.CENTER);
|
||||
this.frame.add(this.image1, BorderLayout.CENTER);
|
||||
} else if(this.numFenetre == 1) {
|
||||
this.image2.setHorizontalAlignment(JLabel.CENTER);
|
||||
this.frame.add(this.image2, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
this.frame.revalidate();
|
||||
this.frame.repaint();
|
||||
|
||||
}
|
||||
}
|
BIN
DEV.3.1/TP/TP2/Galerie.1/GFenetre.class
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/GFenetre.class
Normal file
Binary file not shown.
33
DEV.3.1/TP/TP2/Galerie.1/GFenetre.java
Normal file
33
DEV.3.1/TP/TP2/Galerie.1/GFenetre.java
Normal file
@@ -0,0 +1,33 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class GFenetre extends JFrame {
|
||||
|
||||
private JFrame frame;
|
||||
private JLabel image1;
|
||||
private JLabel image2;
|
||||
private GestionSouris gsouris;
|
||||
|
||||
public GFenetre() {
|
||||
this.frame = new JFrame("Galerie");
|
||||
this.image1 = new JLabel(new ImageIcon("image1.jpeg")); //que gif, png et jpeg
|
||||
this.image2 = new JLabel(new ImageIcon("MICHEL.gif"));
|
||||
this.gsouris = new GestionSouris(this.image2, this);
|
||||
|
||||
this.frame.setSize(1000, 600);
|
||||
this.frame.setLocation(100,100);
|
||||
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
this.image2.setHorizontalAlignment(JLabel.CENTER);
|
||||
this.frame.add(this.image2, BorderLayout.CENTER);
|
||||
|
||||
this.image2.addMouseListener(this.gsouris);
|
||||
this.image1.addMouseListener(this.gsouris);
|
||||
|
||||
|
||||
|
||||
this.frame.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
BIN
DEV.3.1/TP/TP2/Galerie.1/GestionSouris.class
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/GestionSouris.class
Normal file
Binary file not shown.
36
DEV.3.1/TP/TP2/Galerie.1/GestionSouris.java
Normal file
36
DEV.3.1/TP/TP2/Galerie.1/GestionSouris.java
Normal file
@@ -0,0 +1,36 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class GestionSouris implements MouseListener {
|
||||
|
||||
private Component component;
|
||||
private GFenetre gfenetre;
|
||||
|
||||
public GestionSouris(Component component, GFenetre gfenetre) {
|
||||
this.component = component;
|
||||
this.gfenetre = gfenetre;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
int x = e.getX();
|
||||
int width = component.getWidth();
|
||||
|
||||
if(x < width / 2) {
|
||||
//Click à gauche de l'écran
|
||||
System.out.println("click gauche");
|
||||
this.gfenetre.change(0);
|
||||
} else {
|
||||
//Click à droite de l'écran
|
||||
System.out.println("Click droit");
|
||||
this.gfenetre.change(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
}
|
BIN
DEV.3.1/TP/TP2/Galerie.1/MICHEL.gif
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/MICHEL.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 MiB |
BIN
DEV.3.1/TP/TP2/Galerie.1/Main.class
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/Main.class
Normal file
Binary file not shown.
5
DEV.3.1/TP/TP2/Galerie.1/Main.java
Normal file
5
DEV.3.1/TP/TP2/Galerie.1/Main.java
Normal file
@@ -0,0 +1,5 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
GFenetre fenetre = new GFenetre();
|
||||
}
|
||||
}
|
BIN
DEV.3.1/TP/TP2/Galerie.1/image1.jpeg
Normal file
BIN
DEV.3.1/TP/TP2/Galerie.1/image1.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
Reference in New Issue
Block a user