Samegame/ChooseFrameJeuPredefini.java
2021-11-17 18:02:50 +01:00

34 lines
1.1 KiB
Java

/**
*
* @version 1.0
* @author Tanguy Domergue et Leni Boscher
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.*;
public class ChooseFrameJeuPredefini extends JFrame //cette fenetre ouvre les repertoire de l'utilisateur pour rentrer des fichiers prédéfini
{
public ChooseFrameJeuPredefini()
{
this.setTitle("Jeu2");
Dimension dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
int height = (int)dimension.getHeight();
int width = (int)dimension.getWidth();
this.setSize(width, height);
this.setVisible(true);
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Fichier texte", "txt");
chooser.setFileFilter(filter);
this.add(chooser);
int returnVal = chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
new FrameJeu(chooser.getSelectedFile());
this.dispose();
}
}
}