Example #1
0
 private void doSave() {
   if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
     try {
       SerGrid sg = sGrid.getSerGrid();
       File file = fc.getSelectedFile();
       String aPath = file.getAbsolutePath();
       if (!aPath.toLowerCase().endsWith(".ssud")) {
         aPath = aPath + ".ssud";
         file = new File(aPath);
       }
       LoadSaver.save(sg, file);
       fc.setSelectedFile(file);
     } catch (Exception e) {
       e.printStackTrace();
       JOptionPane.showMessageDialog(
           this, "Sudoku game have not been saved!", "Error", JOptionPane.ERROR_MESSAGE);
     }
   }
 }