-
Notifications
You must be signed in to change notification settings - Fork 25
/
GmMenu.java
78 lines (66 loc) · 1.71 KB
/
GmMenu.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
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
74
75
76
77
78
/*
* Copyright (C) 2006 IsmAvatar <IsmAvatar@gmail.com>
* Copyright (C) 2007 Quadduc <quadduc@gmail.com>
*
* This file is part of LateralGM.
* LateralGM is free software and comes with ABSOLUTELY NO WARRANTY.
* See LICENSE for details.
*/
package org.lateralgm.components;
import static org.lateralgm.components.GmMenuBar.setTextAndAlt;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import org.lateralgm.main.LGM;
import org.lateralgm.main.Listener;
import org.lateralgm.messages.Messages;
public class GmMenu extends JMenu
{
private static final long serialVersionUID = 1L;
public GmMenu(String s)
{
super();
setTextAndAlt(this,s);
}
public GmMenu()
{
super();
}
public JMenuItem addItem(String key)
{
return addItem(key,Listener.getInstance());
}
public JMenuItem addItem(String key, ActionListener listener)
{
JMenuItem item = new JMenuItem();
if (key != null)
{
setTextAndAlt(item,Messages.getString(key));
item.setIcon(LGM.getIconForKey(key));
item.setActionCommand(key);
}
item.setAccelerator(KeyStroke.getKeyStroke(Messages.getKeyboardString(key)));
item.addActionListener(listener);
add(item);
return item;
}
public GmMenu addMenu(String key)
{
return addMenu(key,Listener.getInstance());
}
public GmMenu addMenu(String key, ActionListener listener)
{
GmMenu item = new GmMenu();
if (key != null)
{
setTextAndAlt(item,Messages.getString(key));
item.setIcon(LGM.getIconForKey(key));
item.setActionCommand(key);
}
//item.setAccelerator(KeyStroke.getKeyStroke(Messages.getKeyboardString(key)));
item.addActionListener(listener);
add(item);
return item;
}
}