-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorMenu.java
More file actions
119 lines (109 loc) · 4.34 KB
/
Copy pathColorMenu.java
File metadata and controls
119 lines (109 loc) · 4.34 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
public class ColorMenu extends JMenu
{
PaintMainWindow mMainWindow;
public ColorMenu(PaintMainWindow mainWindow)
{
super("Color");
mMainWindow = mainWindow;
JMenu colorMenu = new JMenu("Color");
ButtonGroup buttonGroup = new ButtonGroup();
JRadioButtonMenuItem blackMenuItem = new JRadioButtonMenuItem("Black");
buttonGroup.add(blackMenuItem);
add(blackMenuItem);
class BlackLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.black);
}
}
blackMenuItem.addActionListener(new BlackLineMenuOptionListener());
JRadioButtonMenuItem redMenuItem = new JRadioButtonMenuItem("Red");
buttonGroup.add(redMenuItem);
add(redMenuItem);
class RedLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.RED);
}
}
redMenuItem.addActionListener(new RedLineMenuOptionListener());
JRadioButtonMenuItem orangeMenuItem = new JRadioButtonMenuItem("Orange");
buttonGroup.add(orangeMenuItem);
add(orangeMenuItem);
class OrangeLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.orange);
}
}
orangeMenuItem.addActionListener(new OrangeLineMenuOptionListener());
JRadioButtonMenuItem yellowMenuItem = new JRadioButtonMenuItem("Yellow");
buttonGroup.add(yellowMenuItem);
add(yellowMenuItem);
class YellowLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.yellow);
}
}
yellowMenuItem.addActionListener(new YellowLineMenuOptionListener());
JRadioButtonMenuItem greenMenuItem = new JRadioButtonMenuItem("Green");
buttonGroup.add(greenMenuItem);
add(greenMenuItem);
class GreenLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.green);
}
}
greenMenuItem.addActionListener(new GreenLineMenuOptionListener());
JRadioButtonMenuItem blueMenuItem = new JRadioButtonMenuItem("Blue");
buttonGroup.add(blueMenuItem);
add(blueMenuItem);
class BlueLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.blue);
}
}
blueMenuItem.addActionListener(new BlueLineMenuOptionListener());
JRadioButtonMenuItem brownMenuItem = new JRadioButtonMenuItem("Brown");
buttonGroup.add(brownMenuItem);
add(brownMenuItem);
class BrownLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
int r = 153;
int g = 102;
int b = 51;
Color c = new Color(r, g, b);
mMainWindow.getShapeManager().setPenColor(c);
}
}
brownMenuItem.addActionListener(new BrownLineMenuOptionListener());
JRadioButtonMenuItem grayMenuItem = new JRadioButtonMenuItem("Gray");
buttonGroup.add(grayMenuItem);
add(grayMenuItem);
class GrayLineMenuOptionListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
mMainWindow.getShapeManager().setPenColor(Color.gray);
}
}
grayMenuItem.addActionListener(new GrayLineMenuOptionListener());
}
}