first commit
This commit is contained in:
72
TP_DEV3.1/Organisation du code/AppGalerie.java
Normal file
72
TP_DEV3.1/Organisation du code/AppGalerie.java
Normal file
@@ -0,0 +1,72 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
package fr.iutfbleau.projet;
|
||||
|
||||
public class AppGalerie extends JFrame implements MouseListener{
|
||||
|
||||
|
||||
private String[] listeimage = {"image1.png","image2.png","image4.png"};
|
||||
private int IndexImage = 0;
|
||||
private JPanel panneau = new JPanel(new BorderLayout());
|
||||
// private JFrame fenetre = new JFrame();
|
||||
private JLabel etiquetteImage = new JLabel();
|
||||
|
||||
public Galerie() {
|
||||
|
||||
|
||||
|
||||
|
||||
super("Confirmation");
|
||||
|
||||
etiquetteImage.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
etiquetteImage.setIcon(new ImageIcon(listeimage[IndexImage]));
|
||||
|
||||
panneau.add(etiquetteImage, BorderLayout.CENTER);
|
||||
panneau.addMouseListener(this);
|
||||
setContentPane(panneau);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {} // Appui sur le bouton de la souris
|
||||
|
||||
public void mouseReleased(MouseEvent e) {} // Relâchement du bouton
|
||||
|
||||
public void mouseEntered(MouseEvent e) {} // Souris entre dans le composant
|
||||
|
||||
|
||||
public void mouseExited(MouseEvent e) {} // Souris sort du composant
|
||||
|
||||
public void mouseClicked(MouseEvent e){
|
||||
|
||||
int largeurpanel = panneau.getWidth();
|
||||
|
||||
if(e.getX () > largeurpanel/2 ){
|
||||
|
||||
imageSuivante();
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
imagePrecedente();
|
||||
}
|
||||
}
|
||||
|
||||
private void imageSuivante() {
|
||||
IndexImage = (IndexImage + 1) % listeimage.length;
|
||||
etiquetteImage.setIcon(new ImageIcon(listeimage[IndexImage]));
|
||||
}
|
||||
|
||||
private void imagePrecedente() {
|
||||
IndexImage = (IndexImage - 1 + listeimage.length) % listeimage.length;
|
||||
etiquetteImage.setIcon(new ImageIcon(listeimage[IndexImage]));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
AppGalerie test = new Galerie();
|
||||
|
||||
test.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
10
TP_DEV3.1/Organisation du code/GalerieTest.java
Normal file
10
TP_DEV3.1/Organisation du code/GalerieTest.java
Normal file
@@ -0,0 +1,10 @@
|
||||
public class GalerieTest {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
AppGalerie test = new Galerie();
|
||||
|
||||
test.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package fr.iutflbeau.projet.view;
|
||||
import fr.iutfbleau.projet.controller.ValidationChoix;
|
||||
import fr.iutfbleau.projet.modele.*;
|
||||
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
public class FenetreQuizz extends JFrame implements ActionListener {
|
||||
|
||||
private Question[] questionsquiz;
|
||||
private ChoixUitlisateur choix;
|
||||
private int index = 0;
|
||||
private boolean valide = false;
|
||||
|
||||
private JPanel zoneCentre new JPanel(new BorderLayout());
|
||||
private JButton boutonPrecedent = new JButton("Précédent");
|
||||
private JButton boutonSuivant = new JButton("Suivant");
|
||||
private JButton boutonValider = new JButton("Valider");
|
||||
|
||||
private EcranQuestion EcranDeBase;
|
||||
|
||||
public FenetreQuizz(Question[] questionsquiz) {
|
||||
|
||||
|
||||
super("QCM");
|
||||
this.questionsquiz = questionsquiz;
|
||||
this.choix = new ChoixUitlisateur(questionsquiz.length);
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(zoneCentre, BorderLayout.CENTER);
|
||||
|
||||
boutonSuivant.addActionListener(this);
|
||||
boutonPrecedent.addActionListener(this);
|
||||
boutonValider.addActionListener(this);
|
||||
|
||||
mettreAJourEcran();
|
||||
|
||||
this.setSize(520, 320);
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e){
|
||||
|
||||
Object source = e.getSource();
|
||||
|
||||
|
||||
if(source == boutonPrecedent){
|
||||
|
||||
AllerPrecedent();
|
||||
|
||||
}
|
||||
|
||||
if(source == boutonSuivant){
|
||||
|
||||
AllerSuivant();
|
||||
}
|
||||
|
||||
if(source == boutonValider) {
|
||||
|
||||
Valider();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
BIN
TP_DEV3.1/Organisation du code/projet/AppGalerie.jar
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/AppGalerie.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
TP_DEV3.1/Organisation du code/projet/build/images/image1.png
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/build/images/image1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
TP_DEV3.1/Organisation du code/projet/build/images/image2.png
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/build/images/image2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
BIN
TP_DEV3.1/Organisation du code/projet/build/images/image4.png
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/build/images/image4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
BIN
TP_DEV3.1/Organisation du code/projet/projet.jar
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/projet.jar
Normal file
Binary file not shown.
BIN
TP_DEV3.1/Organisation du code/projet/res/images/image1.png
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/res/images/image1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
TP_DEV3.1/Organisation du code/projet/res/images/image2.png
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/res/images/image2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
BIN
TP_DEV3.1/Organisation du code/projet/res/images/image4.png
Normal file
BIN
TP_DEV3.1/Organisation du code/projet/res/images/image4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,72 @@
|
||||
package fr.iutfbleau.projet;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.net.URL;
|
||||
|
||||
public class AppGalerie extends JFrame implements MouseListener {
|
||||
|
||||
// 1) Chemins DANS LE JAR (=> classpath)
|
||||
private String[] listeImage = {
|
||||
"images/image1.png",
|
||||
"images/image2.png",
|
||||
"images/image4.png"
|
||||
};
|
||||
private int indexImage = 0;
|
||||
|
||||
private JPanel panneau = new JPanel(new BorderLayout());
|
||||
private JLabel etiquetteImage = new JLabel();
|
||||
|
||||
public AppGalerie() {
|
||||
super("Confirmation");
|
||||
|
||||
etiquetteImage.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
etiquetteImage.setIcon(chargerIcone(listeImage[indexImage])); // <-- ICI
|
||||
|
||||
panneau.add(etiquetteImage, BorderLayout.CENTER);
|
||||
panneau.addMouseListener(this);
|
||||
|
||||
setContentPane(panneau);
|
||||
setSize(800, 600);
|
||||
setLocationRelativeTo(null);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
// === MouseListener ===
|
||||
@Override public void mouseClicked(MouseEvent e) {
|
||||
int largeurPanel = panneau.getWidth();
|
||||
if (e.getX() >= largeurPanel / 2) imageSuivante();
|
||||
else imagePrecedente();
|
||||
}
|
||||
@Override public void mousePressed(MouseEvent e) {}
|
||||
@Override public void mouseReleased(MouseEvent e) {}
|
||||
@Override public void mouseEntered(MouseEvent e) {}
|
||||
@Override public void mouseExited(MouseEvent e) {}
|
||||
|
||||
// === Navigation ===
|
||||
private void imageSuivante() {
|
||||
indexImage = (indexImage + 1) % listeImage.length;
|
||||
etiquetteImage.setIcon(chargerIcone(listeImage[indexImage])); // <-- ICI
|
||||
}
|
||||
private void imagePrecedente() {
|
||||
indexImage = (indexImage - 1 + listeImage.length) % listeImage.length;
|
||||
etiquetteImage.setIcon(chargerIcone(listeImage[indexImage])); // <-- ICI
|
||||
}
|
||||
|
||||
// === CHARGEMENT VIA CLASSPATH ===
|
||||
private ImageIcon chargerIcone(String cheminDansJar) {
|
||||
URL url = getClass().getClassLoader().getResource(cheminDansJar);
|
||||
if (url == null) {
|
||||
// debug utile si un nom est faux
|
||||
throw new IllegalArgumentException("Ressource introuvable: " + cheminDansJar);
|
||||
}
|
||||
return new ImageIcon(url);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AppGalerie test = new AppGalerie();
|
||||
|
||||
test.setVisible(true);
|
||||
}
|
||||
}
|
||||
70
TP_DEV3.1/Organisation du code/test/AppGalerie.java
Normal file
70
TP_DEV3.1/Organisation du code/test/AppGalerie.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package fr.iutfbleau.projet;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.net.URL;
|
||||
|
||||
public class AppGalerie extends JFrame implements MouseListener {
|
||||
|
||||
// 1) Chemins DANS LE JAR (=> classpath)
|
||||
private String[] listeImage = {
|
||||
"images/image1.png",
|
||||
"images/image2.png",
|
||||
"images/image4.png"
|
||||
};
|
||||
private int indexImage = 0;
|
||||
|
||||
private JPanel panneau = new JPanel(new BorderLayout());
|
||||
private JLabel etiquetteImage = new JLabel();
|
||||
|
||||
public AppGalerie() {
|
||||
super("Confirmation");
|
||||
|
||||
etiquetteImage.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
etiquetteImage.setIcon(chargerIcone(listeImage[indexImage])); // <-- ICI
|
||||
|
||||
panneau.add(etiquetteImage, BorderLayout.CENTER);
|
||||
panneau.addMouseListener(this);
|
||||
|
||||
setContentPane(panneau);
|
||||
setSize(800, 600);
|
||||
setLocationRelativeTo(null);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
// === MouseListener ===
|
||||
@Override public void mouseClicked(MouseEvent e) {
|
||||
int largeurPanel = panneau.getWidth();
|
||||
if (e.getX() >= largeurPanel / 2) imageSuivante();
|
||||
else imagePrecedente();
|
||||
}
|
||||
@Override public void mousePressed(MouseEvent e) {}
|
||||
@Override public void mouseReleased(MouseEvent e) {}
|
||||
@Override public void mouseEntered(MouseEvent e) {}
|
||||
@Override public void mouseExited(MouseEvent e) {}
|
||||
|
||||
// === Navigation ===
|
||||
private void imageSuivante() {
|
||||
indexImage = (indexImage + 1) % listeImage.length;
|
||||
etiquetteImage.setIcon(chargerIcone(listeImage[indexImage])); // <-- ICI
|
||||
}
|
||||
private void imagePrecedente() {
|
||||
indexImage = (indexImage - 1 + listeImage.length) % listeImage.length;
|
||||
etiquetteImage.setIcon(chargerIcone(listeImage[indexImage])); // <-- ICI
|
||||
}
|
||||
|
||||
// === CHARGEMENT VIA CLASSPATH ===
|
||||
private ImageIcon chargerIcone(String cheminDansJar) {
|
||||
URL url = getClass().getClassLoader().getResource(cheminDansJar);
|
||||
if (url == null) {
|
||||
// debug utile si un nom est faux
|
||||
throw new IllegalArgumentException("Ressource introuvable: " + cheminDansJar);
|
||||
}
|
||||
return new ImageIcon(url);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(() -> new AppGalerie().setVisible(true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user