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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
| package IHM;
import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import Internation.Langue;
import Moteur.Config;
public class Fenetre extends JFrame implements ActionListener{
/**
*
*/
static Config Conf = new Config();
static Langue lang = new Langue();
static IconeTache it = new IconeTache();
/*
* Définition des elements dépendant des langues de l'IHM
*/
// Menu
protected static JMenu FichMenu;
protected static JMenu LangueMenu;
protected static JMenu ParaMenu;
protected static JMenu helpMenu;
//Item de Menu
//Créer les items des menus
protected static JMenuItem QuitAction;
protected static JMenuItem idpsAction;
protected static JMenuItem apdAction;
public Fenetre(){
//Detection de la langue de l'utilisateur
if(lang.getLangue().equals("")) lang.FonctionBundle(System.getProperty("user.language"));
System.out.println(System.getProperty("user.language"));
}
public void actionPerformed(ActionEvent event)
{
System.out.println("Elément de menu [" + event.getActionCommand() + "] utilisé.");
// Traiter les cliques du menu
// Quitter
if( event.getActionCommand().equals(Langue.getAnInternationalizeString("quitter")))
{
System.exit(0); // Quitte le programme de façon Définitive
}
if( event.getActionCommand().equals(Langue.getAnInternationalizeString("idps")))
{
System.out.println("Changement de l'IdClient");
// Déclaration de la fenetre qui permet de changer l'identifiant
//final IdPs idclient = new IdPs();
//idclient.setVisible(true);
}
if( event.getActionCommand().equals(Langue.getAnInternationalizeString("anglais")))
{
System.out.println("Changement de langue");
lang.FonctionBundle("en");
Reload();
}
if( event.getActionCommand().equals(Langue.getAnInternationalizeString("francais")))
{
System.out.println("Changement de langue");
lang.FonctionBundle("fr");
Reload();
}
}
public void Reload()
{
System.out.println(" Langue en cours " + lang.getLangue());
//Définit un titre pour votre fenêtre
this.setTitle("TITRE" + " : " + Conf.getIdClient() );
//Définit une taille
this.setSize(1024, 768);
//Definit la position au centre de l'écran
this.setLocationRelativeTo(null);
//Cache la fenetre
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
/*
* Icone de la barre de titre de la fenetre
*/
Image icone = Toolkit.getDefaultToolkit().getImage("img/logo_m.png");
this.setIconImage(icone);
//Couleurs
Color bps = new Color(0,76,152);
Color yps = new Color(255,221,0);
Color bas = new Color(0,70,148);
Color yas = new Color(251,224,26);
//Créer la Barre de menu
JMenuBar menuBar = new JMenuBar();
//Ajoute la Barre de menu à la fenetre
this.setJMenuBar(menuBar);
//menuBar.setBackground(yps);
//Définition de la Barre de menu
FichMenu = new JMenu(Langue.getAnInternationalizeString("fichier"));
LangueMenu = new JMenu(Langue.getAnInternationalizeString("langue"));
ParaMenu = new JMenu(Langue.getAnInternationalizeString("parametre"));
helpMenu = new JMenu("?");
//Ajouter les menus à la barre de menu
menuBar.add(FichMenu);
menuBar.add(LangueMenu);
menuBar.add(ParaMenu);
menuBar.add(helpMenu);
//Créer les items des menus
QuitAction = new JMenuItem(Langue.getAnInternationalizeString("quitter"));
idpsAction = new JMenuItem(Langue.getAnInternationalizeString("idps"));
apdAction = new JMenuItem(Langue.getAnInternationalizeString("apd"));
//Ne dépend pas du language utilisé
JMenuItem frAction = new JMenuItem("Français", new ImageIcon("flag/FR.png") );
JMenuItem ukAction = new JMenuItem("English", new ImageIcon("flag/EN.png"));
JMenuItem deAction = new JMenuItem("Deutsch", new ImageIcon("flag/DE.png"));
JMenuItem esAction = new JMenuItem("Español", new ImageIcon("flag/ES.png"));
JMenuItem itAction = new JMenuItem("Italiano", new ImageIcon("flag/IT.png"));
JMenuItem nlAction = new JMenuItem("Nederlanders", new ImageIcon("flag/NL.png"));
// Ajouter les items au menu
FichMenu.add(QuitAction);
LangueMenu.add(frAction);
LangueMenu.add(ukAction);
LangueMenu.add(deAction);
LangueMenu.add(esAction);
LangueMenu.add(itAction);
LangueMenu.add(nlAction);
ParaMenu.add(idpsAction);
helpMenu.add(apdAction);
//Ajout d'une action sur les sélections des menus
QuitAction.addActionListener(this);
frAction.addActionListener(this);
ukAction.addActionListener(this);
deAction.addActionListener(this);
esAction.addActionListener(this);
itAction.addActionListener(this);
nlAction.addActionListener(this);
idpsAction.addActionListener(this);
apdAction.addActionListener(this);
//Ajout des onglets à la frame
// Onglets onglets = new Onglets();
// this.add(onglets);
MenuGauche meng = new MenuGauche();
this.add(meng);
this.setVisible(true);
}
public static void main(String[] args) throws InterruptedException {
/*
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) { }
// new SwingApplication(); //Create and show the GUI.
try { //com.sun.java.swing.plaf.windows.WindowsLookAndFeel
//javax.swing.plaf.metal.MetalLookAndFeel
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
Fenetre fen = new Fenetre();
fen.Reload();
it.BarredeTache();
}
} |
Partager