/** Save a file. Called when the user goes to File -> Save */ public void saveFile() { try { calendar.saveCal(calendar.getSettings().getFilename()); } catch (IOException e) { System.out.println(e.getMessage()); } }
/** Save a file as something else. Called when the user goes to File -> Save As */ public void saveFileAs() { JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(new CakeFileChooser()); chooser.setDialogType(JFileChooser.SAVE_DIALOG); chooser.showSaveDialog(window); File f = chooser.getSelectedFile(); if (f == null) return; try { if (calendar.getSettings().getName() == CakeCal.UNTITLED) { calendar.getSettings().setName(f.getName()); parent.updateGUI(CakeCal.UNTITLED); } calendar.saveCal(f.getPath()); } catch (IOException e) { System.out.println(e.getMessage()); } calendar.getSettings().setFilename(f.getPath()); // save.setEnabled(calendar.modified); }