Exemplo n.º 1
0
 private void resetButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_resetButtonActionPerformed
   // TODO add your handling code here:
   String input = new String(passwordField.getPassword());
   if (pM.checkParentPassword(input)) {
     try {
       int n =
           JOptionPane.showConfirmDialog(
               this,
               "Would you like to reset every setting of the game?",
               "Warning",
               JOptionPane.YES_NO_OPTION);
       if (n == JOptionPane.YES_OPTION) {
         session.logout();
         FileUtils.deleteDirectory(manager.getDirectory());
         resposeLabel.setText("Successful.");
         // change the logout button visibility in the main frame
         MainFrame frame = (MainFrame) javax.swing.SwingUtilities.getWindowAncestor(this);
         frame.logoutButton.setVisible(false);
         controller.goToInitialSetup();
       }
     } catch (IOException ex) {
       resposeLabel.setText("Error!");
       Logger.getLogger(ResetGamePanel.class.getName()).log(Level.SEVERE, null, ex);
     }
   } else {
     resposeLabel.setText("Wrong password! Try again.");
   }
 } // GEN-LAST:event_resetButtonActionPerformed