⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphicapp.java

📁 这用java语言模拟一个银行的操作系统
💻 JAVA
字号:
import java.io.*;
import java.util.*;
import javax.swing.* ;
import java.awt.event.*;
import java.io.*;
import java.awt.*;

class graphicApp extends JFrame {
	private static Personne cl=null;
	private static Compte cp=null;

  	private JMenuBar barreMenu ;
  	private JMenu menuFichier,menuClient,menuCompte,menuHelp,menuWindow;
  	private JMenuItem menuFichierOuvrir,menuFichierFermer,menuFichierQuitter,
	
	menuClientCreer, menuClientRechercher, menuClientAfficher,menuClientModifier,menuClientAfficherTous,
	
	menuCompteCreer, menuCompteRechercher,menuCompteAfficher,menuCompteModifier,menuCompteDepot,
	menuCompteRetrait,menuCompteSolde,menuCompteHistorique,menuCompteAfficherTous,
	menuHelpAbout,menuWindowClear;

	private JTextArea textArea;

  public graphicApp(){
    setTitle ("Bancaire de Andre");
    setSize(400,300);
	setResizable(true);
    barreMenu = new JMenuBar();
    setJMenuBar(barreMenu);
	/* creation du menu Fichier et ses trois options Ouvrir , Quitter ,Fermer*/
	menuFichier = new JMenu ("Fichier");
	menuFichier.setMnemonic('F');
	menuFichierOuvrir = new JMenuItem("Ouvrir");
	menuFichierOuvrir.setMnemonic('O');
    menuFichierOuvrir.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){executerActionOuvrir();}
     });
	menuFichierFermer = new JMenuItem("Fermer");
	menuFichierFermer.setMnemonic('F');
	menuFichierQuitter = new JMenuItem("Quitter");
	menuFichierQuitter.setMnemonic('Q');
    menuFichierQuitter.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){executerActionQuitter();}
      });
    menuFichier.add(menuFichierOuvrir);
	menuFichier.addSeparator();
	menuFichier.add(menuFichierFermer);
	menuFichier.addSeparator();
    menuFichier.add(menuFichierQuitter);

    
	
	
	
//Client	
	menuClient = new JMenu ("Client");
	menuClient.setMnemonic('C');
    menuClientCreer = new JMenuItem("Creer");
	menuClientCreer.setMnemonic('C'); 
    menuClientCreer.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){executerActionCreerNouveauClient();}
    });
    menuClientRechercher= new JMenuItem("Rechercher");
	menuClientRechercher.setMnemonic('R');
	menuClientRechercher.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){executerActionrechercherclient();}});

    menuClientAfficherTous= new JMenuItem("AfficherTous");
	menuClientAfficherTous.setMnemonic('T');
	menuClientAfficherTous.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){executerActionAfficherClient();}});

	menuClientAfficher = new JMenuItem("Afficher");
	menuClientAfficher.setMnemonic('A');
	menuClientAfficher.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){executerActionAfficherunClient();}});

	menuClientModifier = new JMenuItem("Modifier");
    menuClientModifier.setMnemonic('M');
	menuClientModifier.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){executerActionModifierunClient();}});
    menuClient.add(menuClientCreer);
	menuClient.addSeparator();
    menuClient.add(menuClientRechercher);
	menuClient.addSeparator();
    menuClient.add(menuClientAfficher);
	menuClient.addSeparator();
    menuClient.add(menuClientAfficherTous);
	menuClient.addSeparator();
	menuClient.add(menuClientModifier);
    
	

	

//Compte

    menuCompte = new JMenu ("Compte");
	menuCompte.setMnemonic('P');
	menuCompteCreer = new JMenuItem("Creer");
	menuCompteCreer.setMnemonic('C');
	menuCompteCreer.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){executerActionCreerCompte();}});
    	
    menuCompteRechercher = new JMenuItem("Rechercher");
	menuCompteRechercher.setMnemonic('R');
	menuCompteRechercher.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){executerActionrecherchercompte();}});
	menuCompteAfficher = new JMenuItem("Afficher");
	menuCompteAfficher.setMnemonic('A');
	menuCompteAfficher.addActionListener(new ActionListener(){
    	public void actionPerformed(ActionEvent e){executerActionAfficherunCompte();}});

	menuCompteAfficherTous = new JMenuItem("AfficherTous");
	menuCompteAfficherTous.setMnemonic('T');
	menuCompteAfficherTous.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){executerActionAfficherCompte();}});
    
	menuCompteModifier = new JMenuItem("Modifier");
	menuCompteModifier.setMnemonic('M');
	menuCompteModifier.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent e){executerModifierCompte();}});
	
	menuCompteDepot = new JMenuItem("CompteDepot");
	menuCompteDepot.setMnemonic('D');
	menuCompteDepot.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent e){executerCompteDepot();}});
	
	menuCompteRetrait = new JMenuItem("CompteRetrait");
	menuCompteRetrait.setMnemonic('R');
	menuCompteRetrait.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent e){executerCompteRetrait();}});
	
	menuCompteSolde = new JMenuItem("Solde");
	menuCompteSolde.setMnemonic('S');
	menuCompteSolde.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent e){executerCompteSolde();}});
	
	menuCompteHistorique = new JMenuItem("Historique");
	menuCompteHistorique.setMnemonic('H');
	menuCompteHistorique.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){executerActionAfficherHistorique();}});
		  
    menuCompte.add(menuCompteCreer);
	menuCompte.addSeparator();
    menuCompte.add(menuCompteRechercher);
	menuCompte.addSeparator();
    menuCompte.add(menuCompteAfficher);
    menuCompte.addSeparator();
    menuCompte.add(menuCompteAfficherTous);
    menuCompte.addSeparator();
    menuCompte.add(menuCompteModifier);
	menuCompte.addSeparator();
	menuCompte.add(menuCompteDepot);
	menuCompte.addSeparator();
    menuCompte.add(menuCompteRetrait);
	menuCompte.addSeparator();
	menuCompte.add(menuCompteSolde);
	menuCompte.addSeparator();
	menuCompte.add(menuCompteHistorique);
	
	
		menuHelp= new JMenu("Help");
		menuHelp.setMnemonic('H');
		menuHelpAbout=new JMenuItem("About");
		menuHelpAbout.setMnemonic('A');
		menuHelpAbout.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e){executerActionAbout();}});
		
		menuHelp.add(menuHelpAbout);
		
		
	
		menuWindow= new JMenu("Window");
		menuWindow.setMnemonic('W');
		menuWindowClear=new JMenuItem("Clear");
		menuWindowClear.setMnemonic('C');
		menuWindowClear.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){executerActionClear();}});
		menuWindow.add(menuWindowClear);
	

    barreMenu.add(menuFichier);
    barreMenu.add(menuClient);
    barreMenu.add(menuCompte);
    barreMenu.add(menuHelp);
    barreMenu.add(menuWindow);	
	
		textArea=new JTextArea();
		textArea.setEditable(false);
		
		JPanel Contentpane=(JPanel)getContentPane();
		Contentpane.add(new JScrollPane(textArea));
	
	
	 /*	FilesUtils.lireFichierClient();
	 	FilesUtils.lireFichierCompte();
	 	FilesUtils.lireFichierOperation();*/
}// End constructor



//action


    private void executerActionCreerNouveauClient()
    {
        new ClientWindow(0).show();
	}
	
	
	private void executerActionAfficherClient()
 	{executerActionClear();
	for(int i=0;i<run.nbreclient;i++)
		run.Client[i].Afficher(textArea);
	}
	
	private void executerActionAfficherCompte()
	{executerActionClear();
	for(int i=0;i<run.nbrecompte;i++)
		run.compte[i].Afficher(textArea);
	}
	
	private void executerActionrechercherclient()
	{
	String numeross=JOptionPane.showInputDialog(this,"numeross du client rechercher?");
	if (numeross!=null)
	{
	cl=run.rechercherclient(numeross);
	if(cl==null)
	 {
	 	JOptionPane.showMessageDialog(this,
			  "cette client n'existe pas","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
	 }
	 else
	 {
	 JOptionPane.showMessageDialog(this,
	 	  "Le numeross est correct!Vous pouvez continuer","Bravo",JOptionPane.INFORMATION_MESSAGE);
	   return;
	 }
	}
	}
	
	private void executerActionAfficherunClient()
	{
	executerActionClear();
	if(cl!=null)
	cl.Afficher(textArea);
	else
	{
	 	JOptionPane.showMessageDialog(this,
			  "il faut d'abord rechercher un client","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
	 }
	}

	private void executerActionModifierunClient()
	{
	if(cl!=null)
	new ClientWindow(1).show();
	else
	    {
	 	JOptionPane.showMessageDialog(this,
			  "il faut d'abord rechercher un client","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
	    } 	
	}

	private void executerActionrecherchercompte()
	{
		String numero=JOptionPane.showInputDialog(this,"numero du compte rechercher?");
		if (numero!=null)
		{
	    cp=run.rechercherproprietair(numero);
		if(cp==null)
		{
	 	JOptionPane.showMessageDialog(this,
			  "cette compte n'existe pas","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
	    }
		else
		{
		JOptionPane.showMessageDialog(this,
			  "Le numero est correct!Vous pouvez continuer","Bravo",JOptionPane.INFORMATION_MESSAGE);
		  return;
		}
		}
	}

	private void executerActionAfficherunCompte()
	{	
		executerActionClear();
		if(cp!=null)
		cp.Afficher(textArea);
		else
        {
	 	JOptionPane.showMessageDialog(this,
			  "il faut d'abord rechercher un compte","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
	    }	
	}
	

	private void executerCompteDepot()
	{
		executerActionClear();
		if(cp!=null)
		new ModifierCreditWindow(0).show();
		else
	  	{
		JOptionPane.showMessageDialog(this,
		  "il faut d'abord rechercher un compte","Information",JOptionPane.INFORMATION_MESSAGE);
		  return;
		}	
    }
	
	
	private void executerCompteRetrait()
	{
		executerActionClear();
		if(cp!=null)
		new ModifierCreditWindow(1).show();
		else
	  	{
		JOptionPane.showMessageDialog(this,
		  "il faut d'abord rechercher un compte","Information",JOptionPane.INFORMATION_MESSAGE);
		  return;
		}	
    }
	
	private void executerActionCreerCompte()
	{
		new CompteWindow(0).show();
		FilesUtils.enregistrerLesCompte();
	}
	

	private void executerModifierCompte()
	{
	if(cp!=null)
	new CompteWindow(1).show();
	else
	  	{
		JOptionPane.showMessageDialog(this,
		  "il faut d'abord rechercher un compte","Information",JOptionPane.INFORMATION_MESSAGE);
		  return;
		}	
	}
	
	
	private void executerCompteSolde()
	{
		executerActionClear();
		if(cp==null)
		{
		JOptionPane.showMessageDialog(this,
		  "il faut d'abord rechercher un compte","Information",JOptionPane.INFORMATION_MESSAGE);
		  return;
		}
		else
		{
		cp.setsolde();
		textArea.append("numero:"+cp.getnumero()+"\n");
		textArea.append("solde: "+cp.getsolde()+"\n");
		}
	}
	private void executerActionAfficherHistorique()
	{
		executerActionClear();
		if(cp==null)
		{
		JOptionPane.showMessageDialog(this,
		  "il faut d'abord rechercher un compte","Information",JOptionPane.INFORMATION_MESSAGE);
		  return;
		}
		else if((cp.getoperations()).size()==0)
		{
  		  JOptionPane.showMessageDialog(this,
			  "il n'y a pas de Historique","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
  	}
  		else
		cp.AfficherHistorique(textArea);
	}
	
	
	private void executerActionClear()
	{
	textArea.setText("");
	}
	
	
	
	

  
	void executerActionOuvrir()
	{
		
	   Frame f = new Frame();
	
 	try {
	
 
			FileDialog fd = new FileDialog(f, "Files", FileDialog.LOAD);
	
			fd.show();
	
			String strFile = fd.getDirectory() + fd.getFile();
	 			if (strFile != null)
				{
				 FileInputStream fis = new FileInputStream(strFile);
			     byte[] buf = new byte[10 * 1024];
				 int len = fis.read(buf);
				 textArea.append(new String(buf, 0, len));
				 fis.close();
				 }
				 else
				 {
				 textArea.append("No file");
				 }
				 }
 
		catch (IOException ex)
 			{
				//ex.printStackTrace();
	
	    }

 
  	} 
 

  void executerActionAbout()
  {
  		  JOptionPane.showMessageDialog(this,
			  "Je m'appel HUANG WEI , et mon nom Francais est Andre,merci pour utiliser!","Information",JOptionPane.INFORMATION_MESSAGE);
  		  return;
  }

  void executerActionCouper(){
    JOptionPane.showMessageDialog(this,"Execution de l'action Couper");
  }

  void executerActionCentrer(){
    JOptionPane.showMessageDialog(this,"Execution de l'action Centrer");
  }

  void executerActionAlignerGauche(){
    JOptionPane.showMessageDialog(this,"Execution de l'action Aligner gauche");
  }

  void executerActionQuitter(){
    if (JOptionPane.showConfirmDialog(this, "etes-vous sur de vouloir quitter",
     "Confirmation",JOptionPane.YES_NO_CANCEL_OPTION)==JOptionPane.YES_OPTION)
    System.exit(0);
  }

  protected void processWindowEvent(WindowEvent e){
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING){System.exit(0);}
  }

  public static void main(String[] args) {
    new graphicApp().show();
  }

  public static void modifierclient(String nom,String prenom,int age,String adress,String email,String telephone,String portable)
  {
  	    cl.setnom(nom);
		cl.setprenom(prenom);
		cl.setage(age);
		cl.setadress(adress);
		cl.setemail(email);
		cl.settelephone(telephone);
		cl.setportable(portable);
		
  }
  
  public static Personne getclient()
  {
  	return cl;
  }
  
  public static Compte getcompte()
  {
  	return cp;
  }
  
  public static void modifiercompte(int initSolde)
  {
	cp.setinitSolde(initSolde);
  }
  
  public static void addoperationR(int montant,String raison,String moyen)
  {
    Operation op = new	Operation(cp.getnumero(),'r',montant,raison,moyen);
    cp.ajouteroperation(op);	  
  }
  
  public static void addoperationD(int montant,String raison,String moyen)
  {
    Operation op = new	Operation(cp.getnumero(),'d',montant,raison,moyen);
    cp.ajouteroperation(op);	  
  }
  
}// End class graphicApp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -