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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
//import javax.swing.JScrollPane;
//import javax.swing.JTable;
/**
*
*
*/
public class FenetrePrincipale extends JFrame implements ActionListener{
//Déclaration générale
private JPanel monPanel = new JPanel();
private GridBagConstraints gbc = new GridBagConstraints();
//Déclaration des JLabel
//private JLabel label_bienvenue = new JLabel ("BIENVENUE SUR xxxxxx, Lxxxxx de xxxx xxxx xxxx !");
//Déclaration des JButton
private JButton bouton_ajout = new JButton ("Ajouter...");
private JButton bouton_modif = new JButton ("Modifier...");
private JButton bouton_supp = new JButton ("Supprimer...");
private JButton bouton_rech = new JButton ("Rechercher...");
// private JScrollPane maScrollPanefilm;
// private JTable table_liste_film;
//**************************************************************************
//Création de la Barre du Menu de la fenetre principale
JMenuBar br=new JMenuBar();
//Les Onglets du Menu
JMenu P=new JMenu("Fichier");
JMenu V=new JMenu("Affichage");
JMenu R=new JMenu("Recherche");
JMenu A=new JMenu("Aide");
//Sous Onglets de l'onglet Fichier
JMenuItem Ajout=new JMenuItem("Nouveau...");
JMenuItem Modif=new JMenuItem("Modifier...");
JMenuItem Supp=new JMenuItem("Supprimer...");
JMenuItem Quitter=new JMenuItem("Quitter");
//Sous Onglets de l'onglet Affichage
JMenuItem Actu=new JMenuItem("Actualiser la liste des films");
//Sous Onglets de l'onglet Recherche
JMenuItem Rec_titre=new JMenuItem("Recherche par Titre");
JMenuItem Rec_realisateur=new JMenuItem("Recherche par Réalisateur");
JMenuItem Rec_acteur=new JMenuItem("Recherche par Acteur");
//Sous Onglets de l'onglet Aide
JMenuItem About=new JMenuItem("A propos de xxxxx");
public FenetrePrincipale(){
super();
//Attribution des écouteurs aux sous onglets de la barre de menus
Ajout.addActionListener(this);
About.addActionListener(this);
Supp.addActionListener(this);
Actu.addActionListener(this);
Quitter.addActionListener(this);
bouton_ajout.addActionListener(this);
build();
this.setVisible(true);
}
//**************************************************************************
//******************************************************************************
private void build(){
setTitle("Rxxxxx - Gxxxxxxx");
setSize(1000,768);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//On définit le Grid
monPanel.setLayout (new GridBagLayout());
//On place les label
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets (10,10,10,10);
// gbc.gridx = 3;
//gbc.gridy = 0;
//monPanel.add(label_bienvenue,gbc);
//On place les boutons
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
monPanel.add(bouton_ajout,gbc); //bouton ajouter
gbc.gridx = 2;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
monPanel.add(bouton_modif,gbc); //bouton modifier
gbc.gridx = 4;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
monPanel.add(bouton_supp,gbc); //bouton supprimer
gbc.gridx = 6;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.NONE;
monPanel.add(bouton_rech,gbc); //bouton recherche
//On place le JTable
// gbc.gridx = 0;
//gbc.gridy = 1;
//gbc.gridwidth = 8;
//gbc.weightx=100;
//gbc.weighty=100;
// monPanel.add(maScrollPanefilm,gbc);
//On attache monPanel
this.getContentPane().add(monPanel);
//On integre Les Onglets dans le Menu
br.add(P);
br.add(V);
br.add(R);
br.add(A);
//On ajoute Les Sous-onglets dans leur onglets respectives ds barre de menu "Fichier"
P.add(Ajout);
P.add(Modif);
P.add(Supp);
P.add(Quitter);
V.add(Actu);
R.add(Rec_titre);
R.add(Rec_realisateur);
R.add(Rec_acteur);
A.add(About);
this.setJMenuBar(br);
}
//*************************************************************************************
//**********************************************************************************
public void actionPerformed (ActionEvent e) {
if(e.getActionCommand().equals("Nouveau...")){
new FenetreAjout().setVisible(true);
}
if (e.getActionCommand().equals("A propos de xxxxx")){
new FenetreAbout().setVisible(true);
}
if (e.getActionCommand().equals("Quitter")){
System.exit(0); //Quitte le programme
}
if (e.getSource() == bouton_ajout){
new FenetreAjout().setVisible(true);
}
}
//**************************************************************************************
} |
Partager