-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaveListener.java
41 lines (35 loc) · 1.04 KB
/
SaveListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Notes;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.nio.file.FileAlreadyExistsException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author pokus
*/
public class SaveListener implements ActionListener {
private Core core;
private Window window;
public SaveListener(Window window, Core core){
this.core = core;
this.window = window;
}
@Override
public void actionPerformed(ActionEvent e) {
String[] path = window.getActualPath();
try {
core.addNewNote(path[0], path[1], window.getText());
core.addTasks(window.getTaskPath(), window.getTask());
} catch (FileAlreadyExistsException ex) {
Logger.getLogger(SaveListener.class.getName()).log(Level.SEVERE, null, ex);
}
if(!window.isFrameVisible()){
window.autoSaveStop();
}
}
}