-
Notifications
You must be signed in to change notification settings - Fork 0
/
Roulette.java
180 lines (142 loc) · 6.11 KB
/
Roulette.java
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class Roulette extends JFrame implements ActionListener, MouseListener {
private String name;
private int saldo;
private int puntata;
private Color coloreScelto;
//Frame e label del titolo
private Color buttonsColor = new Color(87,87,87);
private ImageIcon background = new ImageIcon("backgrounds/roulette.png");
private Color buttonsColorHover = new Color(120,120,120);
private JLabel mainLabel = new JLabel();
private JLabel titleLabel = new JLabel();
private Font subTitleFont = new Font("LEMON MILK",Font.BOLD,25);
private Font buttonsFont = new Font("LEMON MILK",Font.BOLD,20);
//Bottoni di gioco e regolamento
private JButton redButton = new JButton("Rosso");
private JButton blackButton = new JButton("Rosso");
private JButton greenButton = new JButton("Rosso");
private JButton regolamentoButton = new JButton("📖");
public Roulette(String name, int puntata,int saldo){
this.name = name;
this.puntata = puntata;
this.saldo=saldo;
this.setTitle("Roulette - Puntata: "+this.puntata+"$");
this.setResizable(false);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(1300,900);
this.setLayout(null);
this.setLocationRelativeTo(null);
this.setVisible(true);
mainLabel.setBounds(0, 0, 1300, 900);
mainLabel.setIcon(background);
titleLabel.setBounds(499, 70, 301, 57);
titleLabel.setText("Puntata: "+this.puntata+"$");
titleLabel.setHorizontalAlignment(JLabel.CENTER);
titleLabel.setForeground(Color.WHITE);
titleLabel.setFont(subTitleFont);
redButton.setBounds(90, 371, 270, 158);
redButton.setText("ROSSO");
redButton.setFont(buttonsFont);
redButton.setVerticalTextPosition(JLabel.CENTER);
redButton.setHorizontalTextPosition(JLabel.CENTER);
redButton.setOpaque(true);
redButton.setFocusable(false);
redButton.setBorder(null);
redButton.setForeground(Color.WHITE);
redButton.setBackground(Color.RED);
redButton.addActionListener(this);
redButton.addMouseListener(this);
blackButton.setBounds(515, 371, 270, 158);
blackButton.setText("NERO");
blackButton.setFont(buttonsFont);
blackButton.setVerticalTextPosition(JLabel.CENTER);
blackButton.setHorizontalTextPosition(JLabel.CENTER);
blackButton.setOpaque(true);
blackButton.setFocusable(false);
blackButton.setBorder(null);
blackButton.setForeground(Color.WHITE);
blackButton.setBackground(Color.BLACK);
blackButton.addActionListener(this);
blackButton.addMouseListener(this);
greenButton.setBounds(940, 371, 270, 158);
greenButton.setText("VERDE");
greenButton.setFont(buttonsFont);
greenButton.setVerticalTextPosition(JLabel.CENTER);
greenButton.setHorizontalTextPosition(JLabel.CENTER);
greenButton.setOpaque(true);
greenButton.setFocusable(false);
greenButton.setBorder(null);
greenButton.setForeground(Color.WHITE);
greenButton.setBackground(new Color(77,164,71));
greenButton.addActionListener(this);
greenButton.addMouseListener(this);
regolamentoButton.setBounds(1110, 709, 100, 100);
regolamentoButton.setFont(new Font("Arial",Font.PLAIN,45));
regolamentoButton.setVerticalTextPosition(JLabel.CENTER);
regolamentoButton.setHorizontalTextPosition(JLabel.CENTER);
redButton.setVerticalAlignment(JLabel.CENTER);
regolamentoButton.setOpaque(true);
regolamentoButton.setFocusable(false);
regolamentoButton.setBorder(null);
regolamentoButton.setForeground(Color.WHITE);
regolamentoButton.setBackground(buttonsColor);
regolamentoButton.addActionListener(this);
regolamentoButton.addMouseListener(this);
this.add(regolamentoButton);
this.add(blackButton);
this.add(greenButton);
this.add(redButton);
this.add(titleLabel);
this.add(mainLabel);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==regolamentoButton){
JOptionPane.showMessageDialog(null, "VINCITE:\n\nROSSO: X2\nNERO: X2\nVERDE: X25", "REGOLAMENTO", JOptionPane.PLAIN_MESSAGE);
}
if(e.getSource()==redButton){
coloreScelto = Color.RED;
this.dispose();
new GiraRoulette(coloreScelto, this.puntata,this.name,this.saldo);
}
if(e.getSource()==greenButton){
coloreScelto = Color.GREEN;
this.dispose();
new GiraRoulette(coloreScelto, this.puntata,this.name,this.saldo);
}
if(e.getSource()==blackButton){
coloreScelto = Color.BLACK;
this.dispose();
new GiraRoulette(coloreScelto, this.puntata,this.name,this.saldo);
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
if(e.getSource()==redButton) redButton.setBackground(new Color(248, 50, 50));
if(e.getSource()==greenButton) greenButton.setBackground(new Color(5, 72, 5));
if(e.getSource()==blackButton) blackButton.setBackground(new Color(20, 28, 20, 207));
if (e.getSource()==regolamentoButton) regolamentoButton.setBackground(buttonsColorHover);
}
@Override
public void mouseExited(MouseEvent e) {
if(e.getSource()==redButton) redButton.setBackground(Color.RED);
if(e.getSource()==greenButton) greenButton.setBackground(new Color(77, 164, 71));
if(e.getSource()==blackButton) blackButton.setBackground(Color.BLACK);
if (e.getSource()==regolamentoButton) regolamentoButton.setBackground(buttonsColor);
}
}