package Fenetres;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Fenetre_Gerer_Profil extends JFrame {

	private JPanel contentPane;
	private Fenetre_Creer_Profil fenetre1;
	private Fenetre_Recherche_Profil fenetre2;
	private Fenetre_Menu fenetre3;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Fenetre_Gerer_Profil frame = new Fenetre_Gerer_Profil();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Fenetre_Gerer_Profil() {
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 607, 502);
		contentPane = new JPanel_Background();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnCreerProfil = new JButton("    Creer Profil");
		Image icon1 = new ImageIcon(this.getClass().getResource("/user.png")).getImage();
		btnCreerProfil.setIcon(new ImageIcon(icon1));
		btnCreerProfil.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				

				if(fenetre1 == null) {
					fenetre1 = new Fenetre_Creer_Profil();
					fenetre1.setVisible(true);
				}
				else {
					
					fenetre1.setVisible(true);
				}		
				
			}
		});
		btnCreerProfil.setBounds(192, 51, 245, 50);
		contentPane.add(btnCreerProfil);
		
		JButton btnModifierProfil = new JButton("    Modifier Profil");
		Image icon2 = new ImageIcon(this.getClass().getResource("/settings.png")).getImage();
		btnModifierProfil.setIcon(new ImageIcon(icon2));
		btnModifierProfil.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				if(fenetre2 == null) {
					fenetre2 = new Fenetre_Recherche_Profil();
					fenetre2.lblNomPersonne.setEnabled(false);
					fenetre2.lblNouveauProfil.setEnabled(false);
					fenetre2.lblPrenomPersonne.setEnabled(false);
					fenetre2.nomPersonne.setEnabled(false);
					fenetre2.nouveauProfil.setEnabled(false);
					fenetre2.prenomPersonne.setEnabled(false);
					fenetre2.SupprimerProfil.setEnabled(false);
					fenetre2.Switchprofil.setEnabled(false);
					fenetre2.setVisible(true);
				}
				else {
					
					fenetre2.setVisible(true);
				}	
				
			}
		});
		btnModifierProfil.setBounds(192, 133, 245, 50);
		contentPane.add(btnModifierProfil);
		
		JButton btnSupprimerProfil = new JButton("   Supprimer Profil");
		Image icon3 = new ImageIcon(this.getClass().getResource("/rubbish.png")).getImage();
		btnSupprimerProfil.setIcon(new ImageIcon(icon3));
		btnSupprimerProfil.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				if(fenetre2 == null) {
					fenetre2 = new Fenetre_Recherche_Profil();
					fenetre2.lblNomPersonne.setEnabled(false);
					fenetre2.lblNouveauProfil.setEnabled(false);
					fenetre2.lblPrenomPersonne.setEnabled(false);
					fenetre2.nomPersonne.setEnabled(false);
					fenetre2.nouveauProfil.setEnabled(false);
					fenetre2.prenomPersonne.setEnabled(false);
					fenetre2.Rechercher.setEnabled(false);
					fenetre2.Switchprofil.setEnabled(false);
					fenetre2.setVisible(true);
				}
				else {
					
					fenetre2.setVisible(true);
				}	
			}
		});
		btnSupprimerProfil.setBounds(192, 218, 245, 50);
		contentPane.add(btnSupprimerProfil);
		
		JButton btnRetour = new JButton("   Retour");
		Image icon4 = new ImageIcon(this.getClass().getResource("/left-arrow.png")).getImage();
		btnRetour.setIcon(new ImageIcon(icon4));
		btnRetour.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				if(fenetre3 == null) {
					fenetre3 = new Fenetre_Menu(); 
					
					fenetre3.setVisible(true);
				}
				else {
					
					fenetre3.setVisible(true);
				}		
				
			}
		});
		btnRetour.setBounds(39, 403, 133, 33);
		contentPane.add(btnRetour);
		
		JButton btnChangerProfilDune = new JButton("  Changer Profil Personne");
		Image icon5 = new ImageIcon(this.getClass().getResource("/exchange.png")).getImage();
		btnChangerProfilDune.setIcon(new ImageIcon(icon5));
		btnChangerProfilDune.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				if(fenetre2 == null) {
					fenetre2 = new Fenetre_Recherche_Profil();
					fenetre2.SupprimerProfil.setEnabled(false);
					fenetre2.Rechercher.setEnabled(false);
					fenetre2.setVisible(true);
				}
				else {
					
					fenetre2.setVisible(true);
				}	
				
			}
		});
		btnChangerProfilDune.setBounds(192, 302, 245, 50);
		contentPane.add(btnChangerProfilDune);
	}

}
