public void save() throws FileNotFoundException {
JFileChooser jc = new JFileChooser();
int op = jc.showSaveDialog(jc);
if (op == JFileChooser.APPROVE_OPTION) {
String file = jc.getSelectedFile().getPath();
File outFile = new File(file);
FileOutputStream outFileStream = new FileOutputStream(outFile, true);
PrintWriter outStream = new PrintWriter(outFileStream);
String surat = null;
surat = this.getNoSurat() + ":" + this.getPerihal() + ":"
+ this.getTglSurat() + "/"
+ this.getTglTerima() + "/"
+ this.getPengirim() + ":"
+ this.getPenerima();
outStream.println(surat);
outStream.close();
JOptionPane.showMessageDialog(null, "Tersimpan !!");
} else {
JOptionPane.showMessageDialog(null, "Surat Masuk Tidak Tersimpan");
}
}
----------------------------------------------------------------
save1 = new JButton("SAVE AS");
save1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Sekre s = new Sekre();
s.setNoSurat(nosurat.getText());
s.setPerihal(perihal.getText());
s.setTglSurat(tglsurat.getText());
s.setTglTerima(tglterima.getText());
s.setPengirim(pengirim.getText());
s.setPenerima(penerima.getText());
try {
s.save();
} catch (IOException ex) {
Logger.getLogger(Sekre.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
Tidak ada komentar:
Posting Komentar