1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| package brahma;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
public class FenetrePrincipale extends JFrame implements WindowListener {
JMenu menuFichier , menuEdition , menuModules;
JMenuBar menuFenetrePrincipale;
JMenuItem menuModulesClasses , menuModulesRaces;
private static final long serialVersionUID = 1L;
// fenetre principale de l'application
public FenetrePrincipale(){
addWindowListener(this);
setTitle("Fenêtre principale Brahma");
setLocation(100, 100);
setVisible(true);
setSize(400, 200);
JMenuBar menuFenetrePrincipale = new JMenuBar();
menuFichier = new JMenu("Fichier"); menuFenetrePrincipale.add(menuFichier);
menuEdition = new JMenu("Edition"); menuFenetrePrincipale.add(menuEdition);
menuModules = new JMenu("Modules"); menuFenetrePrincipale.add(menuModules);
menuModulesClasses = new JMenuItem("Classes"); menuModules.add(menuModulesClasses);
setJMenuBar(menuFenetrePrincipale);
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
System.out.println("Activation fenêtre");}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub}
@Override
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
int quitter = JOptionPane.showConfirmDialog(this, "Etes vous sur de vouloir quitter ?");
if (quitter == JOptionPane.YES_OPTION) {
System.out.println("Fermeture de la fenêtre");
System.exit(0);
}
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
System.out.println("Fenêtre en icone");}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub}
} |
Partager