You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
2.9 KiB
Java
135 lines
2.9 KiB
Java
/**
|
|
*
|
|
*/
|
|
package gui;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.Color;
|
|
|
|
import gui.Boutton;
|
|
import modeles.Labyrinthe;
|
|
import modeles.Marche;
|
|
import modeles.Menu;
|
|
import modeles.Objet;
|
|
import modeles.Personnage;
|
|
import gui.Background;
|
|
import java.awt.Dimension;
|
|
import java.awt.FlowLayout;
|
|
import java.awt.GraphicsConfiguration;
|
|
import java.awt.GridBagConstraints;
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.HeadlessException;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.file.attribute.AclEntry.Builder;
|
|
|
|
import javax.imageio.ImageIO;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JButton;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
|
|
import org.eclipse.swt.SWT;
|
|
|
|
/**
|
|
* @author nicolas
|
|
*
|
|
*/
|
|
public class jeu extends JFrame implements ActionListener {
|
|
JButton continuer =new JButton("Continuer");
|
|
JButton nouvelle = new JButton("Nouvelle Partie");
|
|
|
|
public JPanel panel;
|
|
|
|
public Menu menu;
|
|
|
|
public jeu() throws IOException {
|
|
super();
|
|
build();
|
|
this.menu=new Menu();
|
|
}
|
|
|
|
public void build() throws IOException{
|
|
setTitle("Jeu");
|
|
setSize(593,283);
|
|
setLocationRelativeTo(null);
|
|
setResizable(false);
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
//Création du JLabel pour l'image
|
|
JLabel container = new JLabel(new ImageIcon(this.image()));
|
|
|
|
//Création du layout des boutons
|
|
container.setLayout(new GridBagLayout());
|
|
|
|
|
|
nouvelle.addActionListener(this);
|
|
continuer.addActionListener(this);
|
|
GridBagConstraints c = new GridBagConstraints();
|
|
c.gridx = 0;
|
|
c.gridy = 0;
|
|
container.add(nouvelle);
|
|
|
|
c.gridx = 1;
|
|
c.gridy=0;
|
|
container.add(continuer);
|
|
|
|
this.setContentPane(container);
|
|
this.setVisible(true);
|
|
|
|
}
|
|
|
|
public BufferedImage image() throws IOException {
|
|
BufferedImage image = ImageIO.read(new File("/home/nicolas/eclipse-workspace/Projet_Java/JAVA/PROJET-PMT_STRI1A/test.jpg"));
|
|
return image;
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
|
Récupération des évènements des boutons Nouvelle Partie et Contnuer
|
|
*/
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
Object source=arg0.getSource();
|
|
choix(source);
|
|
|
|
|
|
}
|
|
/*Méthode de traitement des actions sur les boutons*/
|
|
public void choix(Object source) {
|
|
|
|
if(source==nouvelle) {
|
|
System.out.println("1");
|
|
|
|
//menu =new Menu();
|
|
//Création du Labyrinthe
|
|
Labyrinthe lab =new Labyrinthe();
|
|
|
|
//
|
|
this.menu.getJs().setLab(lab);
|
|
//Appel de la méthode menuSelection()
|
|
this.menu.menuSelection(this.menu.getJs().getLab());
|
|
}
|
|
if(source==continuer) {
|
|
System.out.println("2");
|
|
//menu = new Menu();
|
|
//recupMenu(menu);
|
|
//lab = menu.continuer();
|
|
//return lab;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public Menu getMenu() {
|
|
return menu;
|
|
}
|
|
|
|
}
|
|
|
|
|