-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBordas Coloridas
58 lines (47 loc) · 1.69 KB
/
Bordas Coloridas
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
/*
* JDK 20
*
* @Author:Oner
*
*/
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class BordasExp2 extends JFrame {
public BordasExp2() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setPreferredSize(new Dimension(300, 100));
setLayout(new GridLayout(1, 2));
JButton botaoLinhaChanfro = createButton("Linha Chanfro", LineBorder.createBlackLineBorder());
JButton botaoArcoIris = createButton("Arco-Iris", createRainbowBorder());
setLocationRelativeTo(null);
add(botaoArcoIris);
add(botaoLinhaChanfro);
pack();
}
private JButton createButton(String text, Border border) {
JButton button = new JButton(text);
button.setBorder(border);
return button;
}
private Border createRainbowBorder() {
Border[] colorBorders = {
BorderFactory.createLineBorder(Color.orange),
BorderFactory.createLineBorder(Color.yellow),
BorderFactory.createLineBorder(Color.green),
BorderFactory.createLineBorder(Color.blue),
BorderFactory.createLineBorder(Color.magenta)
};
CompoundBorder compoundBorder = new CompoundBorder(Color.red != null ? BorderFactory.createLineBorder(Color.red) : null, colorBorders[0]);
for (int i = 1; i < colorBorders.length; i++) {
compoundBorder = new CompoundBorder(colorBorders[i], compoundBorder);
}
return compoundBorder;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
BordasExp2 bordasExp2 = new BordasExp2();
bordasExp2.setVisible(true);
});
}
}