-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditMenu.java
More file actions
46 lines (43 loc) · 1.65 KB
/
Copy pathEditMenu.java
File metadata and controls
46 lines (43 loc) · 1.65 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
//henry bogardus
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import java.awt.Toolkit;
public class EditMenu extends JMenu
{
PaintMainWindow mMainWindow;
public EditMenu(PaintMainWindow mainWindow)
{
super("Edit");
mMainWindow = mainWindow;
JMenuItem undoMenuItem = new JMenuItem("Undo");
add(undoMenuItem);
undoMenuItem.setMnemonic(KeyEvent.VK_Z);
undoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
class UndoMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().undo();
mMainWindow.getPaintMainPane().refreshDisplay();
}
}
undoMenuItem.addActionListener(new UndoMenuOptionListener());
JMenuItem redoMenuItem = new JMenuItem("Redo");
add(redoMenuItem);
redoMenuItem.setMnemonic(KeyEvent.VK_R);
redoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
class RedoMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().redo();
mMainWindow.getPaintMainPane().refreshDisplay();
}
}
redoMenuItem.addActionListener(new RedoMenuOptionListener());
}
}