-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFractalSettingColor.java
46 lines (40 loc) · 1.17 KB
/
FractalSettingColor.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* An implementation of FractalSetting, is a Color.
*/
public class FractalSettingColor extends FractalSetting {
private final String mLabel;
private Color mColor;
FractalSettingColor(Fractal fractal, Color defaultColor, String label) {
super(fractal);
mColor = defaultColor;
mLabel = label;
}
public Color getValue() {
return mColor;
}
public void setInitialValue(Color color) {
mColor = color;
}
@Override
String getLabel() {
return mLabel;
}
@Override
JComponent buildJComponent() {
final JButton button = new JButton();
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mColor = JColorChooser.showDialog(null, "Choose a color", mColor);
button.setBackground(mColor);
mFractal.invalidate();
}
});
button.setBackground(mColor);
return button;
}
}