IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques en Java Discussion :

methode pour quitter une fenetre


Sujet :

Interfaces Graphiques en Java

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    502
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 502
    Points : 227
    Points
    227
    Par défaut methode pour quitter une fenetre
    bonjour,

    je voudrais savoir comment pour faire quitter ma fenetre avec un bonton qui se trouve
    sur ma fenetre . existe t'il une methode .

    ma fenetre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    public void ihmprincipale()
    	{
    		Container contenu = this.getContentPane();
    		setSize(400,240);
    		contenu.setLayout(new BorderLayout());
    		//
     
    		JPanel panelprincipale =new JPanel();
    		panelprincipale.setLayout(new BorderLayout());
     
    		//
    		JPanel panelnordtext =new JPanel();
    		JLabel Labelprincipale=new JLabel("Creation Article  v1.0");
    		panelnordtext.add(Labelprincipale);
    		panelprincipale.add(BorderLayout.NORTH,panelnordtext);
    		//
    		JPanel panelcentre =new JPanel();
    		panelcentre.setLayout(new GridLayout(4,1));
    		//
    		JPanel panelcentregrid =new JPanel();
    		JLabel Labentreprise =new JLabel("Creation Nouveau Client                 ");
    		panelcentregrid.add(Labentreprise);
     
    	     entreprisecreer =new JButton("Creer");
    	     entreprisecreer.addActionListener(this);
    		panelcentregrid.add(entreprisecreer);
     
    		JButton entreprisemodifier =new JButton("Modifier");
    		panelcentregrid.add(entreprisemodifier);
     
    		panelcentre.add(panelcentregrid);
     
     
     
    		JPanel panelcentregrid1 =new JPanel();
    		JLabel Labcategorie =new JLabel("Creation Seulement Categorie         ");
    		panelcentregrid1.add(Labcategorie);
     
    		JButton Categoriecreer =new JButton("Creer");
    		panelcentregrid1.add(Categoriecreer);
     
    		JButton Categoriemodifier =new JButton("Modifier");
    		panelcentregrid1.add(Categoriemodifier);
    		//
     
    		panelcentre.add(panelcentregrid1);
    		//
     
    		JPanel panelcentregrid2 =new JPanel();
    		JLabel Labsouscategorie =new JLabel("Creation Seulement Sous Categorie");
    		panelcentregrid2.add(Labsouscategorie);
     
    		JButton sousCategoriecreer =new JButton("Creer");
    		panelcentregrid2.add(sousCategoriecreer);
     
    		JButton sousCategoriemodifier =new JButton("Modifier");
    		panelcentregrid2.add(sousCategoriemodifier);
             //
    		panelcentre.add(panelcentregrid2);
    		//
     
    		JPanel panelcentregrid3 =new JPanel();
    		JLabel Labarticle =new JLabel("Creation Article                               ");
    		panelcentregrid3.add(Labarticle);
     
    		JButton articlecreer =new JButton("Creer");
    		panelcentregrid3.add(articlecreer);
     
    		JButton articlemodifier =new JButton("Modifier");
    		panelcentregrid3.add(articlemodifier);
    		//
    		panelcentre.add(panelcentregrid3);
    		panelprincipale.add(BorderLayout.CENTER,panelcentre);
    		//
     
    		JPanel panelsud=new JPanel();
     
     
    		JButton Butsudquitter =new JButton("Quitter");
    		panelsud.add(Butsudquitter);
    		//
    		panelprincipale.add(BorderLayout.SOUTH,panelsud);
    		contenu.add(BorderLayout.SOUTH,panelprincipale);
     
     
     
    	}
    il me fautrait une methode pour que je puisse fermer la fenetre par son propre bonton , ça je ne sais pas faire
    l'implementaion se fera :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    public void actionPerformed(ActionEvent e) {
     
     
    		if(e.getSource().equals(entreprisecreer)) 
    		{
     
    		}}
    merci !

  2. #2
    Membre éclairé Avatar de grabriel
    Inscrit en
    Septembre 2006
    Messages
    946
    Détails du profil
    Informations forums :
    Inscription : Septembre 2006
    Messages : 946
    Points : 730
    Points
    730
    Par défaut
    Salut,

    Tu peux faire comme ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    JButton Butsudquitter =new JButton("Quitter");
    Butsudquitter.addActionListener(new ActionListener(){
    			public void actionPerformed(ActionEvent ev){
    				System.exit(0);
    			}
    		});
    Ca ferme ta fenetre et quitte ton programme bref ca ferme tout.

    Sinon tu peux intercepter la fermeture de ta fenêtre avec un WindowListener au cas ou tu voudrais faire des traitements autres avant de quitter.

    [EDIT]
    Si tu pouvais mettre des majuscules du genre panelPrincipale au lieu de panelprincipale ou butSudQuitter au lieu de Butsudquitter etc.. déjà ça répondrai aux conventions de nommage des variables et de deux ton code sera plus lisible.


    Bon Courage!!!
    [/EDIT]

  3. #3
    Membre actif
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    502
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 502
    Points : 227
    Points
    227
    Par défaut
    merci beaucoup pour ton aide


    merci !

  4. #4
    Candidat au Club
    Inscrit en
    Avril 2007
    Messages
    3
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 3
    Points : 4
    Points
    4
    Par défaut
    salut
    svp j'ai un problème
    est ce qu'on peut fermer la fenètre d'exécution de pascal si on appuie sur un touche.
    par exemple si on appuie sur la touche S la fenetre se ferme automatiquement.
    mercie
    j'attends une répense.

  5. #5
    Membre éclairé Avatar de grabriel
    Inscrit en
    Septembre 2006
    Messages
    946
    Détails du profil
    Informations forums :
    Inscription : Septembre 2006
    Messages : 946
    Points : 730
    Points
    730
    Par défaut
    C'est qui pascal???

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Methode pour fermer une fenetre
    Par Cellendhyll82 dans le forum Débuter avec Java
    Réponses: 2
    Dernier message: 10/01/2010, 18h39
  2. Methode pour quitter une partie de jeux
    Par cinou01 dans le forum Débuter avec Java
    Réponses: 1
    Dernier message: 06/06/2008, 00h17
  3. methode pour exécuter une class dans un jar
    Par yann_p dans le forum Langage
    Réponses: 2
    Dernier message: 18/04/2006, 17h47
  4. [MSSQL2K] methode pour reprendre une BDD incomprehensible
    Par igorzup dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 16/02/2006, 12h44
  5. Réponses: 3
    Dernier message: 27/04/2005, 17h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo