Here's an ActionPerformed code for a logout button :
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
    JOptionPane jop = new JOptionPane();
    int option = jop.showConfirmDialog(null, "Voulez-vous vraiment vous déconnecter?", "Déconnexion", JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
    if(option == JOptionPane.OK_OPTION){
        this.dispose();
        Connexion connexion = new Connexion();
        connexion.setVisible(true);
    }           
}    
Once I click right on the button, the application stops running How can I handle this?
Here's the rest of code for that button
jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sinpec/deco.png"))); 
jButton5.setBorderPainted(false);
jButton5.setContentAreaFilled(false);
jButton5.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/sinpec/deco1.png"))); // NOI18N
jButton5.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButton5ActionPerformed(evt);
    }
});
jPanel1.add(jButton5);
jButton5.setBounds(70, 0, 50, 50);
 
     
    