-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathPaneCodeMenu.java
More file actions
57 lines (43 loc) · 1.32 KB
/
PaneCodeMenu.java
File metadata and controls
57 lines (43 loc) · 1.32 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
package nodebox.client;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
public class PaneCodeMenu extends PaneMenu {
private PaneCodePopup paneCodePopup;
private String menuName = "Code";
public PaneCodeMenu() {
paneCodePopup = new PaneCodePopup();
}
@Override
public String getMenuName() {
return menuName;
}
private void setMenuName(String name) {
menuName = name;
}
@Override
public void mousePressed(MouseEvent e) {
Rectangle bounds = getBounds();
paneCodePopup.show(this, 5, bounds.y + bounds.height - 4);
}
private class PaneCodePopup extends JPopupMenu {
public PaneCodePopup() {
add(new ChangePaneCodeAction("Code", "_code"));
add(new ChangePaneCodeAction("Handle", "_handle"));
}
}
private class ChangePaneCodeAction extends AbstractAction {
private String codeName;
private String codeType;
private ChangePaneCodeAction(String name, String codeType) {
super(name);
this.codeName = name;
this.codeType = codeType;
}
public void actionPerformed(ActionEvent e) {
setMenuName(codeName);
fireActionEvent(codeType);
}
}
}