Пример #1
0
 private void doLoad() {
   if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
     try {
       SerGrid sg = LoadSaver.load(fc.getSelectedFile().getAbsolutePath());
       sGrid.setSerGrid(sg, gg.getGrid());
     } catch (Exception e) {
       e.printStackTrace();
       JOptionPane.showMessageDialog(
           this, "Sudoku game have not been saved!", "Error", JOptionPane.ERROR_MESSAGE);
     }
   }
   sGrid.repaint();
 }
Пример #2
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);
     }
   }
 }