-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJFileButton.java
More file actions
73 lines (38 loc) · 1.49 KB
/
JFileButton.java
File metadata and controls
73 lines (38 loc) · 1.49 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package components;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import gui.NoteLoaderMenu.NoteLoaderGUI;
import utils.Preferences;
public class JFileButton extends JButton{
private File associatedFile;
private ImageIcon buttonIcon = utils.ImageIOUtil.getInstance().getIcon("/resources/images/encrypted_note.png");
public JFileButton(String name, File file) {
super(name);
this.associatedFile = file;
this.setBackground(new Color(97, 102, 109));
this.setForeground(Color.WHITE);
this.setIcon(this.buttonIcon);
this.setToolTipText("Right click to manipulate the file");
this.addActionListener(new NoteLoaderMenuCall());
this.setComponentPopupMenu(new JFileButtonContextMenu(associatedFile));
}
public void setAssociatedFile(File file) {
this.associatedFile = file;
}
public File getAssociatedFile(File file) {
return this.associatedFile;
}
// -------------------- Listener private class ---------------------------------------
private class NoteLoaderMenuCall implements ActionListener{
public NoteLoaderMenuCall() {}
public void actionPerformed(ActionEvent e) {
// TODO -- File's value gets null in this method
NoteLoaderGUI.startGUI(associatedFile);
}
}
// ------------------------------------------------------------------------------------
}