Repository navigation
Expand file tree
/
Copy pathToolsSubPanel.java
More file actions
78 lines (67 loc) · 1.95 KB
/
Copy pathToolsSubPanel.java
File metadata and controls
78 lines (67 loc) · 1.95 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
package java_paint;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*
* The ToolsSubPanel class contains a button for setting the brush color, a checkBox for enable
* the fill of our drawings and an slider to configure our brush thickness.
*
* @author
*
*/
public class ToolsSubPanel extends JPanel implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private JLabel thicknessLabel;
private JLabel colorLabel;
private JLabel spaceLabel1;
private JLabel spaceLabel2;
private JSlider thicknessSlider;
private JButton colorButton;
private JCheckBox filledCheckBox;
public ToolsSubPanel() {
setupColorButton();
setupThickness();
setupFilledCheckBox();
}
private void setupColorButton() {
colorLabel = new JLabel("Color");
spaceLabel1 = new JLabel(" ");
colorButton = new JButton();
colorButton.setBackground(Color.green);
colorButton.addActionListener(this);
add(colorLabel);
add(colorButton);
add(spaceLabel1);
}
private void setupThickness() {
thicknessLabel = new JLabel("brush thickness");
thicknessSlider = new JSlider(1, 20, 1);
spaceLabel2 = new JLabel(" ");
add(thicknessLabel);
add(thicknessSlider);
add(spaceLabel2);
}
private void setupFilledCheckBox() {
filledCheckBox = new JCheckBox("filled");
add(filledCheckBox);
}
public JSlider getThicknessSlider() {
return thicknessSlider;
}
public JButton getColorButton() {
return colorButton;
}
public boolean isCheckBoxSelected() {
return filledCheckBox.isSelected();
}
@Override
public void actionPerformed(ActionEvent e) {
Color color = JColorChooser.showDialog(null, "Choose Color", Color.yellow);
colorButton.setBackground(color);
}
}