Main.java
1.3 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
package tp2.ColorPicker;
import javax.swing.*;
import java.awt.*;
public class Main {
public static void main(String[] args) {
JFrame win = new JFrame();
BoxLayout mainLayout = new BoxLayout(win.getContentPane(), BoxLayout.X_AXIS);
win.setLayout(mainLayout);
JPanel leftPan = new JPanel();
BoxLayout leftPanLayout = new BoxLayout(leftPan, BoxLayout.Y_AXIS);
leftPan.setLayout(leftPanLayout);
win.add(leftPan);
for (int i = 0; i < 3; i++) {
JPanel row = new JPanel();
JSlider slider = new JSlider();
JTextField field = new JTextField(3);
row.add(slider);
row.add(field);
leftPan.add(row);
}
JPanel rightPane = new JPanel();
BoxLayout rightPaneLayout = new BoxLayout(rightPane, BoxLayout.Y_AXIS);
rightPane.setLayout(rightPaneLayout);
JTextField hexaColor = new JTextField();
rightPane.add(hexaColor);
JPanel color = new JPanel();
color.setBackground(Color.RED);
rightPane.add(color);
win.add(rightPane);
win.setLocationRelativeTo(null);
win.setResizable(false);
win.pack();
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setVisible(true);
}
}