SAe/SAe2.1/commentente/SAé/Precontroleur.java

90 lines
2.9 KiB
Java
Raw Normal View History

2023-06-23 13:40:21 +02:00
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.lang.*;
import javax.imageio.*;
import java.io.*;
public class Precontroleur extends JFrame implements ActionListener{
public Precontroleur() {
super();
JButton berserker = new JButton("BERSERKER");
JButton hero = new JButton("HERO");
JButton mage = new JButton("MAGE");
JButton tank = new JButton("TANK");
JLabel infoberserker = new JLabel("- dégâts x2 mais 150pv de départ");
JLabel infohero = new JLabel("- pas de bonus, 250pv de départ");
JLabel infomage = new JLabel("- pv rendu par potion x2 mais 100pv de départ");
JLabel infotank = new JLabel("- 400pv de départ mais dégâts x0.8");
berserker.setLayout(new GridLayout(2,1));
hero.setLayout(new GridLayout(2,1));
mage.setLayout(new GridLayout(2,1));
tank.setLayout(new GridLayout(2,1));
this.setLayout(new GridLayout(2,2));
this.add(berserker);
this.add(hero);
this.add(mage);
this.add(tank);
try{
berserker.add(new Imag(500, 500, "./images/berserker.png"));
tank.add(new Imag(500, 500, "./images/tank.png"));
mage.add(new Imag(500, 500, "./images/mage.png"));
hero.add(new Imag(500, 500, "./images/hero.png"));
} catch(IOException e){
System.out.println("Erreur d'ouverture");
}
berserker.add(infoberserker);
hero.add(infohero);
mage.add(infomage);
tank.add(infotank);
berserker.addActionListener(this);
hero.addActionListener(this);
mage.addActionListener(this);
tank.addActionListener(this);
berserker.setActionCommand("berserker");
hero.setActionCommand("hero");
mage.setActionCommand("mage");
tank.setActionCommand("tank");
}
public void actionPerformed(ActionEvent evenement){
String commande = new String();
commande="berserker";
if(true==commande.equals(evenement.getActionCommand())){
Controleur fenetre = new Controleur("berserker",150);
fenetre.setSize(1000, 1000);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setVisible(true);
this.dispose();
}
commande="hero";
if(true==commande.equals(evenement.getActionCommand())){
Controleur fenetre = new Controleur("hero",250);
fenetre.setSize(1000, 1000);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setVisible(true);
this.dispose();
}
commande="mage";
if(true==commande.equals(evenement.getActionCommand())){
Controleur fenetre = new Controleur("mage",100);
fenetre.setSize(1000, 1000);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setVisible(true);
this.dispose();
}
commande="tank";
if(true==commande.equals(evenement.getActionCommand())){
Controleur fenetre = new Controleur("tank",400);
fenetre.setSize(1000, 1000);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setVisible(true);
this.dispose();
}
}
}