-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapeMenu.java
More file actions
104 lines (94 loc) · 3.77 KB
/
Copy pathShapeMenu.java
File metadata and controls
104 lines (94 loc) · 3.77 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ShapeMenu extends JMenu
{
PaintMainWindow mMainWindow;
ShapeManager mShapeManager = new ShapeManager(mMainWindow);
public ShapeMenu(PaintMainWindow mainWindow)
{
super("Shape");
mMainWindow = mainWindow;
JMenu shapeMenu = new JMenu("File");
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButtonMenuItem drawDot = new JRadioButtonMenuItem("Dot");
buttonGroup.add(drawDot);
add(drawDot);
class DrawDotMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.DOT);
}
}
drawDot.addActionListener(new DrawDotMenuOptionListener());
JRadioButtonMenuItem drawRectangle = new JRadioButtonMenuItem("Rectangle");
buttonGroup.add(drawRectangle);
add(drawRectangle);
class DrawRectangleMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.RECTANGLE);
}
}
drawRectangle.addActionListener(new DrawRectangleMenuOptionListener());
JRadioButtonMenuItem drawSquare = new JRadioButtonMenuItem("Square");
buttonGroup.add(drawSquare);
add(drawSquare);
class DrawSquareMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.SQUARE);
}
}
drawSquare.addActionListener(new DrawSquareMenuOptionListener());
JRadioButtonMenuItem drawOval = new JRadioButtonMenuItem("Oval");
buttonGroup.add(drawOval);
add(drawOval);
class DrawOvalMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.OVAL);
}
}
drawOval.addActionListener(new DrawOvalMenuOptionListener());
JRadioButtonMenuItem drawCircle = new JRadioButtonMenuItem("Circle");
buttonGroup.add(drawCircle);
add(drawCircle);
class DrawCircleMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.CIRCLE);
}
}
drawCircle.addActionListener(new DrawCircleMenuOptionListener());
JRadioButtonMenuItem drawSegment = new JRadioButtonMenuItem("Segment");
buttonGroup.add(drawSegment);
add(drawSegment);
class DrawSegmentMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.SEGMENT);
}
}
drawSegment.addActionListener(new DrawSegmentMenuOptionListener());
JRadioButtonMenuItem drawFreehand = new JRadioButtonMenuItem("Freehand");
buttonGroup.add(drawFreehand);
add(drawFreehand);
class DrawFreehandMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setShapeID(ShapeID.FREEHAND);
}
}
drawFreehand.addActionListener(new DrawFreehandMenuOptionListener());
}
}