wow le tp là
BIN
DEV3.1/TP01/01_Vote/Main.class
Normal file
9
DEV3.1/TP01/01_Vote/Main.java
Normal file
@@ -0,0 +1,9 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 1) {
|
||||
System.err.println("Entrez une valeur dans la console.");
|
||||
System.exit(0);
|
||||
}
|
||||
Vote v = new Vote(args[0]);
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP01/01_Vote/Vote.class
Normal file
52
DEV3.1/TP01/01_Vote/Vote.java
Normal file
@@ -0,0 +1,52 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
import java.awt.*;
|
||||
import java.sql.*;
|
||||
|
||||
public class Vote {
|
||||
|
||||
private String competiteur;
|
||||
|
||||
public Vote(String competiteur) {
|
||||
this.competiteur = competiteur;
|
||||
|
||||
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 {
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT votants, points FROM pays WHERE competiteur = '" + this.competiteur + "';"
|
||||
);
|
||||
|
||||
ResultSet rs = pst.executeQuery();
|
||||
|
||||
int total = 0;
|
||||
|
||||
while (rs.next()) {
|
||||
total += rs.getInt(2);
|
||||
System.out.println(rs.getString(1) + " " + rs.getInt(2));
|
||||
}
|
||||
|
||||
System.out.println("---------");
|
||||
System.out.println("Total " + total);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
} 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.");
|
||||
}
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP01/02_Victoire/Connexion.class
Normal file
56
DEV3.1/TP01/02_Victoire/Connexion.java
Normal file
@@ -0,0 +1,56 @@
|
||||
import org.mariadb.jdbc.*;
|
||||
import javax.swing.*;
|
||||
import java.sql.*;
|
||||
|
||||
public class Connexion {
|
||||
|
||||
private int scoreMax;
|
||||
private String paysMax;
|
||||
|
||||
public Connexion() {
|
||||
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 {
|
||||
PreparedStatement pst = cnx.prepareStatement(
|
||||
"SELECT SUM(points), competiteur FROM pays GROUP BY competiteur ASC;"
|
||||
);
|
||||
|
||||
ResultSet rs = pst.executeQuery();
|
||||
|
||||
int total = 0;
|
||||
|
||||
rs.next();
|
||||
|
||||
this.scoreMax = rs.getInt(1);
|
||||
this.paysMax = rs.getString(2);
|
||||
|
||||
rs.close();
|
||||
pst.close();
|
||||
} 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 getNomPays() {
|
||||
return this.paysMax;
|
||||
}
|
||||
|
||||
public int getScorePays() {
|
||||
return this.scoreMax;
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP01/02_Victoire/Fenetre.class
Normal file
43
DEV3.1/TP01/02_Victoire/Fenetre.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
private String nomPays;
|
||||
private int scorePays;
|
||||
|
||||
public Fenetre(String nomPays, int scorePays) {
|
||||
this.nomPays = nomPays;
|
||||
this.scorePays = scorePays;
|
||||
|
||||
this.setSize(200, 200);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
JLabel pays = new JLabel(this.nomPays);
|
||||
JLabel score = new JLabel(this.scorePays + "");
|
||||
JPanel south = new JPanel();
|
||||
JButton refresh = new JButton("↻");
|
||||
|
||||
refresh.addActionListener(new Rafraichir(score, pays, this));
|
||||
|
||||
Font policeScore = new Font("Arial", Font.BOLD, 60);
|
||||
Font policePays = new Font("Arial", Font.BOLD, 40);
|
||||
|
||||
score.setFont(policeScore);
|
||||
pays.setFont(policePays);
|
||||
|
||||
pays.setHorizontalAlignment(JLabel.CENTER);
|
||||
score.setHorizontalAlignment(JLabel.CENTER);
|
||||
refresh.setHorizontalAlignment(JButton.RIGHT);
|
||||
|
||||
|
||||
this.add(pays, BorderLayout.NORTH);
|
||||
this.add(score, BorderLayout.CENTER);
|
||||
this.add(south, BorderLayout.SOUTH);
|
||||
south.setLayout(new BorderLayout());
|
||||
south.add(refresh, BorderLayout.EAST);
|
||||
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP01/02_Victoire/Main.class
Normal file
7
DEV3.1/TP01/02_Victoire/Main.java
Normal file
@@ -0,0 +1,7 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Connexion cnx = new Connexion();
|
||||
Fenetre fenetre = new Fenetre(cnx.getNomPays(), cnx.getScorePays());
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP01/02_Victoire/Rafraichir.class
Normal file
25
DEV3.1/TP01/02_Victoire/Rafraichir.java
Normal file
@@ -0,0 +1,25 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class Rafraichir implements ActionListener {
|
||||
|
||||
private JLabel texteScore;
|
||||
private JLabel textePays;
|
||||
private Fenetre fenetre;
|
||||
|
||||
public Rafraichir(JLabel texteScore, JLabel textePays, Fenetre fenetre) {
|
||||
this.texteScore = texteScore;
|
||||
this.textePays = textePays;
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evenement) {
|
||||
Connexion cnx2 = new Connexion();
|
||||
|
||||
this.texteScore.setText(cnx2.getScorePays() + "");
|
||||
this.textePays.setText(cnx2.getNomPays());
|
||||
this.fenetre.repaint();
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/01_Galerie/v1/Controlleur.class
Normal file
52
DEV3.1/TP02/01_Galerie/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/01_Galerie/v1/Fenetre.class
Normal file
18
DEV3.1/TP02/01_Galerie/v1/Fenetre.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(900, 450);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_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));
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/01_Galerie/v1/Main.class
Normal file
6
DEV3.1/TP02/01_Galerie/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/01_Galerie/v1/img1.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP02/01_Galerie/v1/img2.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP02/01_Galerie/v1/img3.jpg
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP02/01_Galerie/v1/img4.jpg
Normal file
After Width: | Height: | Size: 127 KiB |
BIN
DEV3.1/TP02/01_Galerie/v2/Controlleur.class
Normal file
35
DEV3.1/TP02/01_Galerie/v2/Controlleur.java
Normal file
@@ -0,0 +1,35 @@
|
||||
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 int actuel;
|
||||
private CardLayout layout;
|
||||
|
||||
public Controlleur(JLabel[] img, Fenetre fenetre, CardLayout layout) {
|
||||
this.img = img;
|
||||
this.fenetre = fenetre;
|
||||
this.actuel = 0;
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent evenement) {
|
||||
if (evenement.getX() < this.fenetre.getWidth()/2) {
|
||||
this.layout.previous(this.fenetre.getContentPane());
|
||||
}
|
||||
else {
|
||||
this.layout.next(this.fenetre.getContentPane());
|
||||
}
|
||||
this.layout.show(this.fenetre.getContentPane(), "wow");
|
||||
} // 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/01_Galerie/v2/Fenetre.class
Normal file
27
DEV3.1/TP02/01_Galerie/v2/Fenetre.java
Normal file
@@ -0,0 +1,27 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(900, 450);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
CardLayout layout = new CardLayout();
|
||||
this.setLayout(layout);
|
||||
|
||||
JLabel img1 = new JLabel(new ImageIcon("img1.jpg"));
|
||||
JLabel img2 = new JLabel(new ImageIcon("img2.jpg"));
|
||||
JLabel img3 = new JLabel(new ImageIcon("img3.jpg"));
|
||||
JLabel img4 = new JLabel(new ImageIcon("img4.jpg"));
|
||||
|
||||
JLabel[] tableau = {img1, img2, img3, img4};
|
||||
|
||||
this.add(img1);
|
||||
this.add(img2);
|
||||
this.add(img3);
|
||||
this.add(img4);
|
||||
this.addMouseListener(new Controlleur(tableau, this, layout));
|
||||
}
|
||||
}
|
BIN
DEV3.1/TP02/01_Galerie/v2/Main.class
Normal file
6
DEV3.1/TP02/01_Galerie/v2/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/01_Galerie/v2/img1.jpg
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
DEV3.1/TP02/01_Galerie/v2/img2.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
DEV3.1/TP02/01_Galerie/v2/img3.jpg
Normal file
After Width: | Height: | Size: 200 KiB |
BIN
DEV3.1/TP02/01_Galerie/v2/img4.jpg
Normal file
After Width: | Height: | Size: 127 KiB |
BIN
DEV3.1/TP03/01_Boutons/Fenetre.class
Normal file
64
DEV3.1/TP03/01_Boutons/Fenetre.java
Normal file
@@ -0,0 +1,64 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(300, 200);
|
||||
this.setLocation(100, 100);
|
||||
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
|
||||
this.setLayout(layout);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
JButton b1 = new JButton("1");
|
||||
JButton b2 = new JButton("2");
|
||||
JButton b3 = new JButton("3");
|
||||
JButton b4 = new JButton("4");
|
||||
JButton b5 = new JButton("5");
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridheight = 1;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.weightx = 1.0;
|
||||
gbc.weighty = 1.0;
|
||||
|
||||
this.add(b1, gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
gbc.gridy = 0;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 2;
|
||||
|
||||
this.add(b2, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 2;
|
||||
gbc.gridwidth = 2;
|
||||
gbc.gridheight = 1;
|
||||
|
||||
this.add(b3, gbc);
|
||||
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 1;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 2;
|
||||
|
||||
this.add(b4, gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.gridy = 1;
|
||||
gbc.gridwidth = 1;
|
||||
gbc.gridheight = 1;
|
||||
gbc.weightx = 0.0;
|
||||
gbc.weighty = 0.0;
|
||||
|
||||
this.add(b5, gbc);
|
||||
this.addWindowListener(new WindowControler(this));
|
||||
}
|
||||
|
||||
}
|
BIN
DEV3.1/TP03/01_Boutons/Main.class
Normal file
6
DEV3.1/TP03/01_Boutons/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/TP03/01_Boutons/WindowControler.class
Normal file
50
DEV3.1/TP03/01_Boutons/WindowControler.java
Normal file
@@ -0,0 +1,50 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
public class WindowControler implements WindowListener {
|
||||
|
||||
private Fenetre fenetre;
|
||||
|
||||
public WindowControler(Fenetre fenetre) {
|
||||
this.fenetre = fenetre;
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowClosed(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowClosing(WindowEvent evenement) {
|
||||
int resultat = JOptionPane.showConfirmDialog(fenetre, null);
|
||||
if (resultat == JOptionPane.YES_OPTION) {
|
||||
fenetre.dispose();
|
||||
}
|
||||
} // avant fermeture
|
||||
|
||||
|
||||
public void windowDeactivated(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowDeiconified(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowIconified(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void windowOpened(WindowEvent evenement) {
|
||||
|
||||
}
|
||||
}
|