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

Agents de placement/Fenêtres Java Discussion :

Problème de fermeture d'une fenêtre


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Membre du Club
    Inscrit en
    Novembre 2010
    Messages
    221
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 221
    Points : 61
    Points
    61
    Par défaut Problème de fermeture d'une fenêtre
    Salut;
    J'ai un petit problème lors de la création des fenêtre avec NetBeans, au début j'ai une fenêtre Menu(Jframe) qui contient un bouton quand on clique sur le bouton une autre fenêtre s'ouvre, le problème c'est que la fermeture de la seconde fenêtre ferme la fenêtre menu hors que moi je veux pas que cette dernière se ferme jusqu'à ce que je la ferme moi même.
    Je fais quoi pour la garder ouverte même après la fermeture de la seconde fenêtre

  2. #2
    Membre expérimenté
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Points : 1 745
    Points
    1 745
    Par défaut
    Tu peux changer l'opération par défaut lors du clic sur la croix avec la méthode setDefaultCloseOperation de la classe JFrame.

    Les valeurs possibles sont :
    DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object.

    HIDE_ON_CLOSE (defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects.

    DISPOSE_ON_CLOSE (defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects.

    EXIT_ON_CLOSE (defined in JFrame): Exit the application using the System exit method. Use this only in applications.
    Dans ton cas tu dois avoir EXIT_ON_CLOSE par défaut.

  3. #3
    Membre du Club
    Inscrit en
    Novembre 2010
    Messages
    221
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 221
    Points : 61
    Points
    61
    Par défaut
    Citation Envoyé par Mathieu.J Voir le message
    Tu peux changer l'opération par défaut lors du clic sur la croix avec la méthode setDefaultCloseOperation de la classe JFrame.

    Les valeurs possibles sont :


    Dans ton cas tu dois avoir EXIT_ON_CLOSE par défaut.
    j'ai fait ça, mais pareil ça marche pas, dès que je ferme une fenêtre les autres se ferment automatiquement.

  4. #4
    Membre expérimenté
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Points : 1 745
    Points
    1 745
    Par défaut
    Un WindowListener qui traine ?

    Montre ton code, là comme ça je vois rien d'autre.

  5. #5
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    C'est DISPOSE_ON_CLOSE qu'il faut utiliser, cette option fait appel à la émthode dispose de ta fenêtre uniquement, elle n'appelle pas exit, méthode qui va tuer l'ensemble du processus java.
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  6. #6
    Membre du Club
    Inscrit en
    Novembre 2010
    Messages
    221
    Détails du profil
    Informations forums :
    Inscription : Novembre 2010
    Messages : 221
    Points : 61
    Points
    61
    Par défaut
    voila mon code pour la JFrame Menu
    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
    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
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
     
    package sonalgaz;
    /**
     *
     * @author pcfutur
     */
     
    public class Abonne extends javax.swing.JFrame {
     
        /** Creates new form Abonne */
        public Abonne() {
            initComponents();
            this.setSize(360,430);
            this.setLocationRelativeTo(null);
        }
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            numag = new javax.swing.JTextField();
            jLabel3 = new javax.swing.JLabel();
            reference = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            nomab = new javax.swing.JTextField();
            jLabel5 = new javax.swing.JLabel();
            prenomab = new javax.swing.JTextField();
            jLabel6 = new javax.swing.JLabel();
            teleab = new javax.swing.JTextField();
            jLabel7 = new javax.swing.JLabel();
            adrab = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jLabel8 = new javax.swing.JLabel();
            jLabel9 = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Fiche d'abonné");
            setName("Fiche d'abonné"); // NOI18N
            getContentPane().setLayout(null);
     
            jLabel1.setFont(new java.awt.Font("Times New Roman", 3, 18)); // NOI18N
            jLabel1.setForeground(new java.awt.Color(255, 0, 0));
            jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel1.setText("Abonné");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(130, 20, 70, 22);
     
            jLabel2.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
            jLabel2.setForeground(new java.awt.Color(255, 0, 0));
            jLabel2.setText("NumAg:");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(10, 69, 60, 17);
     
            numag.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    numagActionPerformed(evt);
                }
            });
            getContentPane().add(numag);
            numag.setBounds(107, 66, 75, 20);
     
            jLabel3.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
            jLabel3.setForeground(new java.awt.Color(255, 0, 0));
            jLabel3.setText("Référence :");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(10, 100, 80, 17);
     
            reference.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    referenceActionPerformed(evt);
                }
            });
            getContentPane().add(reference);
            reference.setBounds(107, 97, 75, 20);
     
            jLabel4.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
            jLabel4.setForeground(new java.awt.Color(255, 0, 0));
            jLabel4.setText("Nom :");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(10, 131, 60, 17);
            getContentPane().add(nomab);
            nomab.setBounds(107, 128, 217, 20);
     
            jLabel5.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
            jLabel5.setForeground(new java.awt.Color(255, 0, 0));
            jLabel5.setText("Prénom :");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(10, 154, 70, 17);
            getContentPane().add(prenomab);
            prenomab.setBounds(107, 154, 217, 20);
     
            jLabel6.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
            jLabel6.setForeground(new java.awt.Color(255, 0, 0));
            jLabel6.setText("Téléphone :");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(10, 198, 80, 17);
     
            teleab.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    teleabActionPerformed(evt);
                }
            });
            getContentPane().add(teleab);
            teleab.setBounds(107, 192, 217, 20);
     
            jLabel7.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
            jLabel7.setForeground(new java.awt.Color(255, 0, 0));
            jLabel7.setText("Adresse :");
            getContentPane().add(jLabel7);
            jLabel7.setBounds(10, 224, 70, 17);
            getContentPane().add(adrab);
            adrab.setBounds(107, 218, 217, 20);
     
            jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/SaveUp.png"))); // NOI18N
            jButton1.setText("Enregistrer");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
            getContentPane().add(jButton1);
            jButton1.setBounds(10, 279, 140, 33);
     
            jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/effacer.gif"))); // NOI18N
            jButton2.setText("Annuler");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
                }
            });
            getContentPane().add(jButton2);
            jButton2.setBounds(190, 280, 140, 31);
     
            jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/error.png"))); // NOI18N
            jButton3.setText("Quitter");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });
            getContentPane().add(jButton3);
            jButton3.setBounds(108, 323, 120, 31);
            getContentPane().add(jLabel8);
            jLabel8.setBounds(0, 0, 334, 5);
     
            jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/AGENCE.jpg"))); // NOI18N
            getContentPane().add(jLabel9);
            jLabel9.setBounds(0, 0, 360, 390);
     
            pack();
        }// </editor-fold>                        
     
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
        vérification();
    }                                        
     
    private void teleabActionPerformed(java.awt.event.ActionEvent evt) {                                       
     
    }                                      
     
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
        this.setVisible(false);
        System.exit(0);
    }                                        
     
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
        numag.setText(null);
        reference.setText(null);
        nomab.setText(null);
        prenomab.setText(null);
        teleab.setText(null);
        adrab.setText(null);
     
    }                                        
     
    private void numagActionPerformed(java.awt.event.ActionEvent evt) {                                      
    // TODO add your handling code here:
     
    }                                     
     
    private void referenceActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
    }                                         
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see <a href="http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html" target="_blank">http://download.oracle.com/javase/tu...feel/plaf.html</a> 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(Abonne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(Abonne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(Abonne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(Abonne.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
     
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
     
                public void run() {
                    new Abonne().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify                     
        private javax.swing.JTextField adrab;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JLabel jLabel8;
        private javax.swing.JLabel jLabel9;
        private javax.swing.JTextField nomab;
        private javax.swing.JTextField numag;
        private javax.swing.JTextField prenomab;
        private javax.swing.JTextField reference;
        private javax.swing.JTextField teleab;
        // End of variables declaration   
    }       [/quote]        
     
    et voila le code d'un exemple d'une des fenêtre 
     
    [quote]
     package sonalgaz;
     
    import javax.swing.JFrame;
     
    /**
     *
     * @author pcfutur
     */
    public class Agence extends javax.swing.JFrame {
     
        /** Creates new form Agence */
        public Agence() {
            initComponents();
            this.setSize(350,400);
             this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            this.setLocationRelativeTo(null);
        }
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jLabel5 = new javax.swing.JLabel();
            numag = new javax.swing.JTextField();
            nomag = new javax.swing.JTextField();
            adrag = new javax.swing.JTextField();
            teleag = new javax.swing.JTextField();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jLabel6 = new javax.swing.JLabel();
            jLabel7 = new javax.swing.JLabel();
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Fiche d'une agence");
            getContentPane().setLayout(null);
     
            jLabel1.setFont(new java.awt.Font("Times New Roman", 3, 18));
            jLabel1.setForeground(new java.awt.Color(255, 255, 0));
            jLabel1.setText("Agence");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(130, 10, 70, 30);
     
            jLabel2.setFont(new java.awt.Font("Times New Roman", 3, 14));
            jLabel2.setForeground(new java.awt.Color(255, 255, 0));
            jLabel2.setText("Nom :");
            getContentPane().add(jLabel2);
            jLabel2.setBounds(29, 92, 60, 17);
     
            jLabel3.setFont(new java.awt.Font("Times New Roman", 3, 14));
            jLabel3.setForeground(new java.awt.Color(255, 255, 0));
            jLabel3.setText("Adresse :");
            getContentPane().add(jLabel3);
            jLabel3.setBounds(29, 123, 80, 17);
     
            jLabel4.setFont(new java.awt.Font("Times New Roman", 3, 14));
            jLabel4.setForeground(new java.awt.Color(255, 255, 0));
            jLabel4.setText("Téléphone :");
            getContentPane().add(jLabel4);
            jLabel4.setBounds(29, 161, 80, 17);
     
            jLabel5.setFont(new java.awt.Font("Times New Roman", 3, 14));
            jLabel5.setForeground(new java.awt.Color(255, 255, 0));
            jLabel5.setText("NumAg :");
            getContentPane().add(jLabel5);
            jLabel5.setBounds(29, 66, 80, 17);
            getContentPane().add(numag);
            numag.setBounds(168, 63, 158, 20);
            getContentPane().add(nomag);
            nomag.setBounds(165, 89, 161, 20);
     
            adrag.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    adragActionPerformed(evt);
                }
            });
            getContentPane().add(adrag);
            adrag.setBounds(165, 120, 161, 20);
            getContentPane().add(teleag);
            teleag.setBounds(165, 158, 161, 20);
     
            jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/SaveUp.png"))); // NOI18N
            jButton1.setText("Enregistrer");
            getContentPane().add(jButton1);
            jButton1.setBounds(10, 230, 140, 40);
     
            jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/effacer.gif"))); // NOI18N
            jButton2.setText("Annuler");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
                }
            });
            getContentPane().add(jButton2);
            jButton2.setBounds(180, 230, 140, 40);
     
            jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/error.png"))); // NOI18N
            jButton3.setText("Quitter");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });
            getContentPane().add(jButton3);
            jButton3.setBounds(100, 310, 120, 35);
     
            jLabel6.setText(" ");
            getContentPane().add(jLabel6);
            jLabel6.setBounds(0, 0, 3, 14);
     
            jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sonalgaz/ABONNE.jpg"))); // NOI18N
            getContentPane().add(jLabel7);
            jLabel7.setBounds(0, 0, 400, 390);
     
            pack();
        }// </editor-fold>
     
    private void adragActionPerformed(java.awt.event.ActionEvent evt) {                                      
    // TODO add your handling code here:
    }                                     
     
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
        this.setVisible(false);
        System.exit(0);
    }                                        
     
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
        numag.setText(null);
        nomag.setText(null);
        adrag.setText(null);
        teleag.setText(null);
    }                                        
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see <a href="http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html" target="_blank">http://download.oracle.com/javase/tu...feel/plaf.html</a> 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(Agence.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(Agence.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(Agence.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(Agence.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }
            //</editor-fold>
     
            /* Create and display the form */
            java.awt.EventQueue.invokeLater(new Runnable() {
     
                public void run() {
                    new Agence().setVisible(true);
                }
            });
        }
        // Variables declaration - do not modify
        private javax.swing.JTextField adrag;
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JLabel jLabel6;
        private javax.swing.JLabel jLabel7;
        private javax.swing.JTextField nomag;
        private javax.swing.JTextField numag;
        private javax.swing.JTextField teleag;
        // End of variables declaration
    }

  7. #7
    Membre expérimenté
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Points : 1 745
    Points
    1 745
    Par défaut
    Dans ta classe Agence.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    A remplacer par autre chose selon ton besoin. Comme précisé dans les 2 posts précédents.


    EXIT_ON_CLOSE => Provoque l'arrêt de l'application.


    DISPOSE_ON_CLOSE, comme précisé par sinok me parait le plus adapté. Si tu veux faire une meilleur gestion de l'évènement fermeture de la fenêtre, tu dois mettre DO_NOTHING_ON_CLOSE et implémenter un WindowListener.

Discussions similaires

  1. Réponses: 2
    Dernier message: 18/03/2014, 15h36
  2. [WD10] Problème en fermeture d'une fenêtre
    Par bestmoroco dans le forum WinDev
    Réponses: 2
    Dernier message: 05/08/2012, 05h15
  3. [ASP.NET] Problème de fermeture d'une fenêtre
    Par Dadou74 dans le forum ASP.NET
    Réponses: 2
    Dernier message: 08/02/2007, 09h23
  4. executer une fonction à la fermeture d'une fenêtre
    Par Oluha dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 22/02/2005, 09h46
  5. Arrêter un ttmt en cours, lors de la fermeture d'une fenêtre
    Par teska dans le forum Bases de données
    Réponses: 2
    Dernier message: 20/12/2004, 14h08

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