-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor
46 lines (38 loc) · 1.08 KB
/
Color
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 java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author onezer0
*/
public class Cores extends JFrame {
public Cores() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 120);
setLayout(new FlowLayout());
setBackground(Color.yellow);
JPanel panel1 = createColoredPanel(Color.red);
JPanel panel2 = createColoredPanel(Color.blue);
addButtonsToPanel(panel1);
addButtonsToPanel(panel2);
add(panel1);
add(panel2);
}
private JPanel createColoredPanel(Color color) {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.setBackground(color);
return panel;
}
private void addButtonsToPanel(JPanel panel) {
panel.add(new JButton("p1"));
panel.add(new JButton("p2"));
panel.add(new JButton("p3"));
}
public static void main(String[] args) {
Cores cores = new Cores();
cores.setVisible(true);
}
}