46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
import java.awt.*;
|
|
import javax.swing.*;
|
|
import java.awt.event.*;
|
|
import java.util.*;
|
|
import java.io.*;
|
|
|
|
public class Fenetre extends JFrame{
|
|
|
|
static Galerie pan = new Galerie();
|
|
private ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
|
private InputStream file = loader.getResourceAsStream("Galerie.java");
|
|
|
|
public Fenetre(){
|
|
pan.add(Listeimage.liste[Listeimage.index]);
|
|
this.setSize(250, 250);
|
|
this.setLocation(500, 500);
|
|
this.addMouseListener(pan);
|
|
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
|
this.setContentPane(pan);
|
|
|
|
addWindowListener(new WindowAdapter()
|
|
{
|
|
public void windowClosing(WindowEvent e)
|
|
{
|
|
if(fermerFenetre()==true){
|
|
dispose();
|
|
System.exit(0);
|
|
}
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
|
|
private boolean fermerFenetre() {
|
|
JOptionPane option = new JOptionPane("Voulez-vous vraiment quitter ce programme ?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
|
|
JDialog confirmation = option.createDialog(this, "Confirmation de fermeture");
|
|
|
|
confirmation.setSize(400, 120);
|
|
confirmation.setLocation(450, 550);
|
|
confirmation.setVisible(true);
|
|
int result = (int) option.getValue();
|
|
confirmation.dispose();
|
|
return result == JOptionPane.YES_OPTION;
|
|
}
|
|
}
|