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 :

demande de confirmation avant de fermer un jframe


Sujet :

Agents de placement/Fenêtres Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Novembre 2009
    Messages
    89
    Détails du profil
    Informations forums :
    Inscription : Novembre 2009
    Messages : 89
    Par défaut demande de confirmation avant de fermer un jframe
    bonjour!
    un problème au niveau de mon code mais j'arrive pas à réaliser c'est à quel niveau !
    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
     
     
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.WindowAdapter;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
     
    public class accueil extends javax.swing.JFrame {
     
        /** Creates new form accueil */
        public accueil() {
            initComponents();
    initListeners();
        }
        private void initListeners() {
                this.addWindowListener(new ExitListener());
    setDefaultCloseOperation(authentification.DO_NOTHING_ON_CLOSE);
    }
     
    public void exit() {
                int rep =
                        JOptionPane.showConfirmDialog(
                        this,
                        "Voulez vous vraiment quitter ?",
                        "Fermeture de l'application",
                        JOptionPane.YES_NO_OPTION);
                System.out.println("rep :"+rep);
                if (rep == 0) {
     
                    System.exit(0);
                }
            }
     
     public class ExitListener extends WindowAdapter {
                public void windowClosing(WindowEvent e) {
                    exit();
                }
            }
     
        private void initComponents() {
     
            jButton2 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jButton4 = new javax.swing.JButton();
            jButton5 = new javax.swing.JButton();
            jButton6 = new javax.swing.JButton();
            jButton7 = new javax.swing.JButton();
            jButton8 = new javax.swing.JButton();
     
            jButton2.setText("jButton2");
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel1.setText("Interface Gestionnaire");
     
            jButton1.setText("Gérer les emplacements");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
     
            jButton3.setText("Gérer les étages");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });
     
            jButton4.setText("Gérer les gestionnaires");
            jButton4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton4ActionPerformed(evt);
                }
            });
     
            jButton5.setText("Gérer les points d'accès");
            jButton5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton5ActionPerformed(evt);
                }
            });
     
            jButton6.setText("Gèrer les reçus ");
            jButton6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton6ActionPerformed(evt);
                }
            });
     
            jButton7.setText("gèrer les tickets");
            jButton7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton7ActionPerformed(evt);
                }
            });
     
            jButton8.setText("Gèrer les abonnés");
            jButton8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton8ActionPerformed(evt);
                }
            });
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(126, 126, 126)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING))
                    .addContainerGap(127, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(147, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addGap(145, 145, 145))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(23, 23, 23)
                    .addComponent(jLabel1)
                    .addGap(33, 33, 33)
                    .addComponent(jButton1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton8)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton5)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton6)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(33, Short.MAX_VALUE))
            );
     
            pack();
        }
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
                 JFrame frame = new JFrame();
                    frame.setContentPane(new gestionepmlacement());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
                    frame.setVisible(true);
                     }                                        
     
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionetage());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
     
              JFrame frame = new JFrame();
                    frame.setContentPane(new gestiongestionnaire ());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionpointaccès());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionrecu());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionticket());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
          JFrame frame = new JFrame();
                    frame.setContentPane(new gestionepmlacement());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
     
                    accueil acc = new accueil();
     
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
     
     acc.setLocation((screen.width - acc.getSize().width)/2,(screen.height - acc.getSize().height)/2);
     
             acc.setVisible(true);
                }
            });
        }
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JButton jButton4;
        private javax.swing.JButton jButton5;
        private javax.swing.JButton jButton6;
        private javax.swing.JButton jButton7;
        private javax.swing.JButton jButton8;
        private javax.swing.JLabel jLabel1;
        // End of variables declaration
     
    }

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 483
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 483
    Par défaut
    merci d'etre plus précis sur le terme "problème".

  3. #3
    Membre confirmé
    Profil pro
    Ingénieur
    Inscrit en
    Mars 2009
    Messages
    152
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur

    Informations forums :
    Inscription : Mars 2009
    Messages : 152
    Par défaut
    A quoi correspond la variable "authentification"? Il ne vaudrait pas mieux la remplacer par "JFrame" ?

  4. #4
    Membre Expert Avatar de Ivelios
    Homme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2008
    Messages
    1 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 031
    Par défaut
    Tu n'as pas fait
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    import java.awt.event.WindowEvent;
    Tu pourrais fractionner le code des évènements, ça se répète beaucoup

    laurentze +1

  5. #5
    Membre expérimenté Avatar de Torg666
    Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2008
    Messages
    230
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2008
    Messages : 230
    Par défaut
    Citation Envoyé par élève_ingénieur Voir le message
    bonjour!
    un problème au niveau de mon code mais j'arrive pas à réaliser c'est à quel niveau !
    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
     
     
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.WindowAdapter;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
     
    public class accueil extends javax.swing.JFrame {
     
        /** Creates new form accueil */
        public accueil() {
            initComponents();
    initListeners();
        }
        private void initListeners() {
                this.addWindowListener(new ExitListener());
    setDefaultCloseOperation(authentification.DO_NOTHING_ON_CLOSE);
    }
     
    public void exit() {
                int rep =
                        JOptionPane.showConfirmDialog(
                        this,
                        "Voulez vous vraiment quitter ?",
                        "Fermeture de l'application",
                        JOptionPane.YES_NO_OPTION);
                System.out.println("rep :"+rep);
                if (rep == 0) {
     
                    System.exit(0);
                }
            }
     
     public class ExitListener extends WindowAdapter {
                public void windowClosing(WindowEvent e) {
                    exit();
                }
            }
     
        private void initComponents() {
     
            jButton2 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jButton4 = new javax.swing.JButton();
            jButton5 = new javax.swing.JButton();
            jButton6 = new javax.swing.JButton();
            jButton7 = new javax.swing.JButton();
            jButton8 = new javax.swing.JButton();
     
            jButton2.setText("jButton2");
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            jLabel1.setText("Interface Gestionnaire");
     
            jButton1.setText("Gérer les emplacements");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });
     
            jButton3.setText("Gérer les étages");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });
     
            jButton4.setText("Gérer les gestionnaires");
            jButton4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton4ActionPerformed(evt);
                }
            });
     
            jButton5.setText("Gérer les points d'accès");
            jButton5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton5ActionPerformed(evt);
                }
            });
     
            jButton6.setText("Gèrer les reçus ");
            jButton6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton6ActionPerformed(evt);
                }
            });
     
            jButton7.setText("gèrer les tickets");
            jButton7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton7ActionPerformed(evt);
                }
            });
     
            jButton8.setText("Gèrer les abonnés");
            jButton8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton8ActionPerformed(evt);
                }
            });
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(126, 126, 126)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING))
                    .addContainerGap(127, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(147, Short.MAX_VALUE)
                    .addComponent(jLabel1)
                    .addGap(145, 145, 145))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(23, 23, 23)
                    .addComponent(jLabel1)
                    .addGap(33, 33, 33)
                    .addComponent(jButton1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton3)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton8)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton5)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton6)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(33, Short.MAX_VALUE))
            );
     
            pack();
        }
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
                 JFrame frame = new JFrame();
                    frame.setContentPane(new gestionepmlacement());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
                    frame.setVisible(true);
                     }                                        
     
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionetage());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
     
              JFrame frame = new JFrame();
                    frame.setContentPane(new gestiongestionnaire ());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionpointaccès());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionrecu());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      JFrame frame = new JFrame();
                    frame.setContentPane(new gestionticket());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
                     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
          JFrame frame = new JFrame();
                    frame.setContentPane(new gestionepmlacement());
                    frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
                    frame.pack();
                    this.dispose();
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((screen.width - frame.getSize().width)/2,(screen.height - frame.getSize().height)/2);
     frame.setVisible(true);
        }                                        
     
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
     
                    accueil acc = new accueil();
     
     Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
     
     acc.setLocation((screen.width - acc.getSize().width)/2,(screen.height - acc.getSize().height)/2);
     
             acc.setVisible(true);
                }
            });
        }
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JButton jButton4;
        private javax.swing.JButton jButton5;
        private javax.swing.JButton jButton6;
        private javax.swing.JButton jButton7;
        private javax.swing.JButton jButton8;
        private javax.swing.JLabel jLabel1;
        // End of variables declaration
     
    }
    Dans inticomponents():
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    Essaie:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

Discussions similaires

  1. Réponses: 1
    Dernier message: 07/05/2007, 23h26
  2. script pour demander une confirmation avant d effacer
    Par pierrot10 dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 09/10/2006, 11h46
  3. [resolulu][SWING] action avant de fermer une JFrame
    Par berg dans le forum Agents de placement/Fenêtres
    Réponses: 2
    Dernier message: 18/06/2006, 00h15
  4. Réponses: 4
    Dernier message: 04/04/2006, 17h09
  5. Confirmation avant de fermer une fenetre
    Par Dauphin dans le forum C++Builder
    Réponses: 10
    Dernier message: 26/05/2005, 01h27

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