forked from lucasmartiniano6/mc322-projeto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuPromocao.java
More file actions
118 lines (100 loc) · 3.1 KB
/
Copy pathMenuPromocao.java
File metadata and controls
118 lines (100 loc) · 3.1 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import java.awt.FlowLayout;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Toolkit;
// Classe não utilizada no código, realizaria a escolha de promoção
public class MenuPromocao {
private JFrame window;
private JPanel panel;
private final Tabuleiro tabuleiro;
private JButton opcaoCavalo;
private JButton opcaoBispo;
private JButton opcaoTorre;
private JButton opcaoRainha;
private JLabel label;
private String type = null;
// Construtor
public MenuPromocao(Tabuleiro tabuleiro){
this.tabuleiro = tabuleiro;
gerarJanela();
makeBackground();
}
// Gets e Sets
public String getValor() {
return type;
}
public void setValor(String type) {
this.type = type;
}
public void setWindow(JFrame window) {
this.window = window;
}
public JFrame getWindow(){
return window;
}
public JPanel getPanel() {
return panel;
}
public void setPanel(JPanel panel) {
this.panel = panel;
}
public Dimension getResolucao(){
Toolkit tool = Toolkit.getDefaultToolkit();
return tool.getScreenSize();
}
public Tabuleiro getTabuleiro() {
return tabuleiro;
}
public void makeBackground() {
label = new JLabel("Escolha a peça da promoção:");
opcaoCavalo = new JButton("Cavalo");
opcaoBispo = new JButton("Bispo");
opcaoTorre = new JButton("Torre");
opcaoRainha = new JButton("Rainha");
JPanel panel = new JPanel();
getWindow().add(panel);
panel.setLayout(new FlowLayout());
panel.add(label);
panel.add(opcaoCavalo);
panel.add(opcaoBispo);
panel.add(opcaoTorre);
panel.add(opcaoRainha);
panel.setVisible(true);
opcaoCavalo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setValor("cavalo");
getWindow().dispose();
}
});
opcaoBispo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setValor("bispo");
getWindow().dispose();
}
});
opcaoTorre.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setValor("torre");
getWindow().dispose();
}
});
opcaoRainha.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setValor("raiha");
getWindow().dispose();
}
});
getWindow().revalidate();
}
public void gerarJanela(){
setWindow((new JFrame()));
getWindow().setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getWindow().setSize(200, 175);
getWindow().setLocationRelativeTo(null);
getWindow().setVisible(true);
}
}