-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrayListener.java
More file actions
72 lines (61 loc) · 1.59 KB
/
TrayListener.java
File metadata and controls
72 lines (61 loc) · 1.59 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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Notes;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.Action;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
/**
*
* @author pokus
*/
public class TrayListener implements MouseListener {
private JPopupMenu pop;
private Window window;
public TrayListener(Window window){
this.window = window;
this.pop = new JPopupMenu();
JMenuItem item = new JMenuItem("Exit");
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
pop.add(item);
pop.pack();
}
@Override
public void mouseClicked(MouseEvent e) {
Point p = e.getLocationOnScreen();
switch(e.getButton()){
case 1:
window.toogleVisibility();
window.setActualCalendar();
pop.setVisible(false);
break;
default:
pop.setVisible(true);
pop.setLocation(p.x, p.y);
break;
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}