fini ex 1 du transition

This commit is contained in:
2024-09-12 15:19:28 +02:00
parent 0f828b31cf
commit 6e4a3d85d0
29 changed files with 876 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,47 @@
import java.sql.*;
public class Vote{
public static void main (String[] arg){
try{
Class.forName("org.mariadb.jdbc.Driver");
}catch(ClassNotFoundException e){
System.err.println("pas de disponibilité");
System.exit(1);
}
try{
Connection bd = DriverManager.getConnection(
"jdbc:mariadb://dwarves.iut-fbleau.fr/felix-vi",
"felix-vi", "felix-vi");
try{
PreparedStatement pst = bd.prepareStatement(
"SELECT votants, points FROM Vote WHERE competiteur = ?");
pst.setString(1, arg[0]);
ResultSet rs = pst.executeQuery();
try{
int total = 0;
while(rs.next()) {
total += rs.getInt(2);
System.out.print(rs.getString(1));
System.out.print(" ");
System.out.println(rs.getInt(2));
}
System.out.print("Total ");
System.out.println(total);
rs.close();
}catch(SQLException e){
System.err.println("mal affichage");
System.exit(1);
}
pst.close();
}catch(SQLException e){
System.err.println("mal execute");
System.exit(1);
}
bd.close();
}catch(SQLException e){
System.err.println("mauvais mdp");
System.exit(1);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,59 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Controller_galerie implements MouseListener{
private int indice;
private int max_indice;
private String[] tab;
private JFrame page;
private JLabel image;
public Controller_galerie(String[] tab){
this.tab = tab;
this.indice = 0;
this.max_indice = this.tab.length-1;
}
public void SetPage(JFrame page, JLabel image){
this.page = page;
this.image = image;
}
@Override
public void mouseClicked(MouseEvent e) {
Component taille = (Component) e.getComponent();
if (e.getX()>taille.getWidth()/2){
if (this.indice == this.max_indice){
this.indice = 0;
}else{
this.indice++;
}
}else if (e.getX()<taille.getWidth()/2){
if (this.indice == 0){
this.indice = this.max_indice;
}else{
this.indice--;
}
}
System.out.println(this.indice);
System.out.println(taille.getWidth()/2);
this.page.remove(this.image);
this.image = new JLabel(new ImageIcon(this.tab[this.indice]));
this.image.addMouseListener(this);
this.page.add(this.image);
this.page.revalidate();
}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {}
}

Binary file not shown.

View File

@@ -0,0 +1,11 @@
import javax.swing.*;
import java.awt.*;
public class Galerie{
public static void main(String[] args){
String[] tab = {"Untitled.jpg", "chat.jpg", "hiboux.jpg"};
Controller_galerie controller = new Controller_galerie(tab);
View_galerie vue = new View_galerie();
vue.affichage(tab[0],controller);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

View File

@@ -0,0 +1,15 @@
import javax.swing.*;
import java.awt.*;
public class View_galerie{
public void affichage(String nom, Controller_galerie controller){
JFrame fenetre = new JFrame();
fenetre.setSize(500, 300);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel image = new JLabel(new ImageIcon(nom));
controller.SetPage(fenetre,image);
image.addMouseListener(controller);
fenetre.add(image);
fenetre.setVisible(true);
}
}

BIN
DEV3.1/transition/chat.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB