fin TP03
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.class
Normal file
Binary file not shown.
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.java
Normal file
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonNon.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
public class ControleurBoutonNon implements ActionListener {
|
||||
|
||||
private JDialog fenetre;
|
||||
|
||||
public ControleurBoutonNon(JDialog fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
fenetre.dispose();
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.class
Normal file
Binary file not shown.
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.java
Normal file
18
DEV3.1/TP02/02_Confirmation/v1/ControleurBoutonOui.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
|
||||
public class ControleurBoutonOui implements ActionListener {
|
||||
|
||||
private JFrame fenetre;
|
||||
|
||||
public ControleurBoutonOui(JFrame fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.fenetre.dispose();
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.class
Normal file
Binary file not shown.
43
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.java
Normal file
43
DEV3.1/TP02/02_Confirmation/v1/ControleurFenetre.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
public class ControleurFenetre implements WindowListener {
|
||||
|
||||
private JFrame fenetre;
|
||||
|
||||
public ControleurFenetre(JFrame fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
|
||||
public void windowClosing(WindowEvent evenement){
|
||||
JDialog fermeture = new JDialog(this.fenetre, "Fermeture");
|
||||
fermeture.setLayout(new BorderLayout());
|
||||
JLabel texte = new JLabel("Voulez-vous vraiment quitter ?");
|
||||
texte.setHorizontalAlignment(JLabel.CENTER);
|
||||
fermeture.add(texte, BorderLayout.CENTER);
|
||||
JPanel panneau = new JPanel();
|
||||
panneau.setLayout(new FlowLayout());
|
||||
JButton oui = new JButton("Oui");
|
||||
oui.addActionListener(new ControleurBoutonOui(this.fenetre));
|
||||
JButton non = new JButton("Non");
|
||||
non.addActionListener(new ControleurBoutonNon(fermeture));
|
||||
panneau.add(oui);
|
||||
panneau.add(non);
|
||||
fermeture.add(panneau, BorderLayout.SOUTH);
|
||||
fermeture.setLocation(400, 275);
|
||||
fermeture.setSize(300, 100);
|
||||
fermeture.setVisible(true);
|
||||
} // avant fermeture
|
||||
|
||||
|
||||
|
||||
public void windowActivated(WindowEvent evenement) {} // premier plan
|
||||
public void windowClosed(WindowEvent evenement){} // après fermeture
|
||||
public void windowDeactivated(WindowEvent evenement){} // arrière-plan
|
||||
public void windowDeiconified(WindowEvent evenement){} // restauration
|
||||
public void windowIconified(WindowEvent evenement){} // minimisation
|
||||
public void windowOpened(WindowEvent evenement){} // après ouverture
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/Controlleur.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/Controlleur.class
Normal file
Binary file not shown.
52
DEV3.1/TP02/02_Confirmation/v1/Controlleur.java
Normal file
52
DEV3.1/TP02/02_Confirmation/v1/Controlleur.java
Normal file
@@ -0,0 +1,52 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class Controlleur implements MouseListener {
|
||||
|
||||
private JLabel img;
|
||||
private Fenetre fenetre;
|
||||
private String[] images;
|
||||
private int actuel;
|
||||
|
||||
public Controlleur(JLabel img, Fenetre fenetre) {
|
||||
this.img = img;
|
||||
this.fenetre = fenetre;
|
||||
String[] temp = {
|
||||
"img1.jpg",
|
||||
"img2.jpg",
|
||||
"img3.jpg",
|
||||
"img4.jpg"
|
||||
};
|
||||
|
||||
this.images = temp;
|
||||
this.actuel = 0;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent evenement) {
|
||||
if (evenement.getX() < this.fenetre.getWidth()/2) {
|
||||
this.actuel--;
|
||||
if (this.actuel == -1) {
|
||||
this.actuel = 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.actuel++;
|
||||
if (this.actuel == 4) {
|
||||
this.actuel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.fenetre.getContentPane().removeAll();
|
||||
this.fenetre.add(new JLabel(new ImageIcon(this.images[this.actuel])));
|
||||
this.fenetre.revalidate();
|
||||
this.fenetre.repaint();
|
||||
} // un bouton cliqué
|
||||
|
||||
|
||||
public void mouseEntered(MouseEvent evenement) {} // debut du survol
|
||||
public void mouseExited(MouseEvent evenement) {} // fin du survol
|
||||
public void mousePressed(MouseEvent evenement) {} // un bouton appuyé
|
||||
public void mouseReleased(MouseEvent evenement) {} // un bouton relâché
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/Fenetre.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/Fenetre.class
Normal file
Binary file not shown.
19
DEV3.1/TP02/02_Confirmation/v1/Fenetre.java
Normal file
19
DEV3.1/TP02/02_Confirmation/v1/Fenetre.java
Normal file
@@ -0,0 +1,19 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(900, 450);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
|
||||
this.setLayout(new GridLayout(1, 1));
|
||||
|
||||
JLabel img = new JLabel(new ImageIcon("img1.jpg"));
|
||||
|
||||
this.add(img);
|
||||
this.addMouseListener(new Controlleur(img, this));
|
||||
this.addWindowListener(new ControleurFenetre(this));
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/Main.class
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/Main.class
Normal file
Binary file not shown.
6
DEV3.1/TP02/02_Confirmation/v1/Main.java
Normal file
6
DEV3.1/TP02/02_Confirmation/v1/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/02_Confirmation/v1/img1.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP02/02_Confirmation/v1/img2.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP02/02_Confirmation/v1/img3.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP02/02_Confirmation/v1/img4.jpg
Normal file
BIN
DEV3.1/TP02/02_Confirmation/v1/img4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 127 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
DEV3.1/TP03/02_Tableau/Donnees.class
Normal file
BIN
DEV3.1/TP03/02_Tableau/Donnees.class
Normal file
Binary file not shown.
114
DEV3.1/TP03/02_Tableau/Donnees.java
Normal file
114
DEV3.1/TP03/02_Tableau/Donnees.java
Normal file
@@ -0,0 +1,114 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.awt.*;
|
||||
import java.sql.*;
|
||||
|
||||
public class Donnees {
|
||||
|
||||
private String[] modules;
|
||||
private String[] champs;
|
||||
private int[] idChamps;
|
||||
|
||||
public Donnees() {
|
||||
// FAIRE UN TABLEAU PAR TABLE DE LA BASE DE DONNEES AU LIEU DE RASSEMBLER LES DEUX
|
||||
|
||||
try {
|
||||
Connection cnx = DriverManager.getConnection(
|
||||
"jdbc:mariadb://dwarves.iut-fbleau.fr/simoes",
|
||||
"simoes", "simoes"
|
||||
);
|
||||
|
||||
try {
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e2) {
|
||||
System.err.println("Problème de pilote.");
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// QUERY 1
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT * FROM module;"
|
||||
);
|
||||
|
||||
ResultSet rs = pst.executeQuery();
|
||||
|
||||
rs.last();
|
||||
|
||||
this.modules = new String[rs.getInt(1)];
|
||||
|
||||
rs.first();
|
||||
|
||||
int i = 0;
|
||||
this.modules[i] = rs.getString(2);
|
||||
|
||||
while (rs.next()) {
|
||||
i++;
|
||||
this.modules[i] = rs.getString(2);
|
||||
}
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
|
||||
// QUERY 2
|
||||
|
||||
PreparedStatement pst2 = cnx.prepareStatement(
|
||||
"SELECT COUNT(*) FROM champ;"
|
||||
);
|
||||
|
||||
ResultSet rs2 = pst2.executeQuery();
|
||||
|
||||
rs2.last();
|
||||
|
||||
this.idChamps = new int[rs2.getInt(1)];
|
||||
this.champs = new String[rs2.getInt(1)];
|
||||
|
||||
rs2.close();
|
||||
pst2.close();
|
||||
|
||||
// QUERY 3
|
||||
PreparedStatement pst3 = cnx.prepareStatement(
|
||||
"SELECT * FROM champ;"
|
||||
);
|
||||
|
||||
ResultSet rs3 = pst3.executeQuery();
|
||||
|
||||
i = 0;
|
||||
|
||||
while (rs3.next()) {
|
||||
this.idChamps[i] = rs3.getInt(1);
|
||||
this.champs[i] = rs3.getString(2);
|
||||
i++;
|
||||
}
|
||||
|
||||
for (i = 0; i != this.champs.length; i++) {
|
||||
System.out.println(this.idChamps[i] + " | " + this.champs[i]);
|
||||
}
|
||||
|
||||
rs3.close();
|
||||
pst3.close();
|
||||
|
||||
// TODO
|
||||
|
||||
} catch (SQLException e3) {
|
||||
System.err.println("Erreur de syntaxe SQL.");
|
||||
}
|
||||
|
||||
cnx.close();
|
||||
} catch (SQLException e1) {
|
||||
System.err.println("Erreur de connexion à la base de données.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String[] getModules() {
|
||||
return this.modules;
|
||||
}
|
||||
|
||||
public int[] getIdChamps() {
|
||||
return this.idChamps;
|
||||
}
|
||||
|
||||
public String[] getChamps() {
|
||||
return this.champs;
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP03/02_Tableau/Fenetre.class
Normal file
BIN
DEV3.1/TP03/02_Tableau/Fenetre.class
Normal file
Binary file not shown.
77
DEV3.1/TP03/02_Tableau/Fenetre.java
Normal file
77
DEV3.1/TP03/02_Tableau/Fenetre.java
Normal file
@@ -0,0 +1,77 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
private String[] modules;
|
||||
private String[] champs;
|
||||
private int[] idChamps;
|
||||
|
||||
public Fenetre(String[] modules, String[] champs, int[] idChamps) {
|
||||
this.modules = modules;
|
||||
this.champs = champs;
|
||||
this.idChamps = idChamps;
|
||||
|
||||
int[] nbChampsParModule = new int[this.modules.length];
|
||||
|
||||
Arrays.fill(nbChampsParModule, 0);
|
||||
|
||||
int indexIdChamps = 0;
|
||||
|
||||
for (int i = 0; i != this.modules.length; i++) {
|
||||
while ((indexIdChamps < this.idChamps.length) && this.idChamps[indexIdChamps] == (i+1)) {
|
||||
nbChampsParModule[i]++;
|
||||
indexIdChamps++;
|
||||
}
|
||||
System.out.println(nbChampsParModule[i]);
|
||||
}
|
||||
|
||||
System.out.println(Arrays.toString(nbChampsParModule));
|
||||
|
||||
this.setSize(200, 500);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
this.setLayout(new GridBagLayout());
|
||||
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.fill = GridBagConstraints.BOTH; // Make the component fill its display area entirely
|
||||
gbc.gridwidth = 1;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
|
||||
|
||||
for (int i = 0; i != this.modules.length; i++) {
|
||||
gbc.gridheight = nbChampsParModule[i];
|
||||
JLabel texte = new JLabel(this.modules[i]);
|
||||
texte.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
texte.setHorizontalAlignment(JLabel.CENTER);
|
||||
texte.setVerticalAlignment(JLabel.CENTER);
|
||||
this.add(texte, gbc);
|
||||
gbc.gridy += nbChampsParModule[i];
|
||||
}
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridheight = 1;
|
||||
|
||||
|
||||
for (int i = 0; i != this.champs.length; i++) {
|
||||
gbc.gridy = i;
|
||||
JLabel texte = new JLabel(this.champs[i]);
|
||||
texte.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
texte.setHorizontalAlignment(JLabel.CENTER);
|
||||
texte.setVerticalAlignment(JLabel.CENTER);
|
||||
this.add(texte, gbc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
BIN
DEV3.1/TP03/02_Tableau/Main.class
Normal file
BIN
DEV3.1/TP03/02_Tableau/Main.class
Normal file
Binary file not shown.
8
DEV3.1/TP03/02_Tableau/Main.java
Normal file
8
DEV3.1/TP03/02_Tableau/Main.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Donnees donnees = new Donnees();
|
||||
Fenetre fenetre = new Fenetre(donnees.getModules(), donnees.getChamps(), donnees.getIdChamps());
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user