-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.java
More file actions
220 lines (212 loc) · 8.17 KB
/
Settings.java
File metadata and controls
220 lines (212 loc) · 8.17 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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Settings {
static JFrame settings;
JToggleButton grid;
JToggleButton bgmode;
JButton back;
JLabel SnakeColour;
JRadioButton colour1;
JRadioButton colour2;
JRadioButton colour3;
JRadioButton colour4;
JRadioButton colour5;
JRadioButton colour6;
static boolean gridmode=false;
static boolean bg=true;
static boolean c1=false;
static boolean c2=false;
static boolean c3=false;
static boolean c4=false;
static boolean c5=false;
static boolean c6=false;
public static void main(String[] args) {
settings = new JFrame("Settings");
settings.setSize(1100,650);
ImageIcon logo = new ImageIcon("logo.png");
settings.setIconImage(logo.getImage());
settings.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
settings.setLocationRelativeTo(null);
settings.setResizable(false);
JPanel panel = new JPanel();
panel.setLayout(null);
panel.setBackground(Color.BLACK);
panel.setBounds(0,0,1100,650);
panel.setBorder(BorderFactory.createEmptyBorder(100,100,100,100));
JToggleButton grid = new JToggleButton("Grid");
grid.setBackground(Color.GREEN);
grid.setForeground(Color.WHITE);
grid.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
grid.setBorder(BorderFactory.createEtchedBorder());
grid.setBounds(450,50,200,100);
grid.setFocusable(false);
grid.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(grid.isSelected()){
grid.setText("Show Grid");
gridmode = false;
}
else{
grid.setText("Hide Grid");
gridmode = true;
}
}
});
panel.add(grid);
JToggleButton bgmode = new JToggleButton("Background");
bgmode.setBackground(Color.GREEN);
bgmode.setForeground(Color.WHITE);
bgmode.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
bgmode.setBorder(BorderFactory.createEtchedBorder());
bgmode.setBounds(450,200,200,100);
bgmode.setFocusable(false);
bgmode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(bgmode.isSelected()){
bgmode.setText("Dark mode");
bg = false;
}
else{
bgmode.setText("Light Mode");
bg = true;
}
}
});
panel.add(bgmode);
JLabel SnakeColour = new JLabel("Choose the colour of your snake:");
SnakeColour.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
SnakeColour.setForeground(Color.WHITE);
SnakeColour.setBounds(325,300,600,50);
panel.add(SnakeColour);
JRadioButton colour1 = new JRadioButton("Green");
colour1.setBackground(Color.BLACK);
colour1.setForeground(Color.GREEN);
colour1.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
colour1.setBorder(BorderFactory.createEtchedBorder());
colour1.setBounds(300,350,200,50);
colour1.setFocusable(false);
colour1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(colour1.isSelected()){
colour1.setText("Green");
c1 = true;
}
}
});
JRadioButton colour2 = new JRadioButton("Blue");
colour2.setBackground(Color.BLACK);
colour2.setForeground(Color.BLUE);
colour2.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
colour2.setBorder(BorderFactory.createEtchedBorder());
colour2.setBounds(525,350,200,50);
colour2.setFocusable(false);
colour2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(colour2.isSelected()){
colour2.setText("Blue");
c2 = true;
}
}
});
JRadioButton colour3 = new JRadioButton("Red");
colour3.setBackground(Color.BLACK);
colour3.setForeground(Color.RED);
colour3.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
colour3.setBorder(BorderFactory.createEtchedBorder());
colour3.setBounds(725,350,200,50);
colour3.setFocusable(false);
colour3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(colour3.isSelected()){
colour3.setText("Red");
c3 = true;
}
}
});
JRadioButton colour4 = new JRadioButton("Yellow");
colour4.setBackground(Color.BLACK);
colour4.setForeground(Color.YELLOW);
colour4.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
colour4.setBorder(BorderFactory.createEtchedBorder());
colour4.setBounds(300,400,200,50);
colour4.setFocusable(false);
colour4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(colour4.isSelected()){
colour4.setText("Yellow");
c4 = true;
}
}
});
JRadioButton colour5 = new JRadioButton("Orange");
colour5.setBackground(Color.BLACK);
colour5.setForeground(Color.ORANGE);
colour5.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
colour5.setBorder(BorderFactory.createEtchedBorder());
colour5.setBounds(525,400,200,50);
colour5.setFocusable(false);
colour5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(colour5.isSelected()){
colour5.setText("Orange");
c5 = true;
}
}
});
JRadioButton colour6 = new JRadioButton("Rainbow");
colour6.setBackground(Color.BLACK);
colour6.setForeground(Color.MAGENTA);
colour6.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
colour6.setBorder(BorderFactory.createEtchedBorder());
colour6.setBounds(725,400,200,50);
colour6.setFocusable(false);
colour6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(colour6.isSelected()){
colour6.setText("Rainbow");
c6 = true;
}
}
});
ButtonGroup colourGroup = new ButtonGroup();
colourGroup.add(colour1);
colourGroup.add(colour2);
colourGroup.add(colour3);
colourGroup.add(colour4);
colourGroup.add(colour5);
colourGroup.add(colour6);
panel.add(colour1);
panel.add(colour2);
panel.add(colour3);
panel.add(colour4);
panel.add(colour5);
panel.add(colour6);
JButton back = new JButton("Back");
back.setBackground(Color.GREEN);
back.setForeground(Color.WHITE);
back.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
back.setBorder(BorderFactory.createEtchedBorder());
back.setBounds(450,500,200,100);
back.setFocusable(false);
back.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Menu.main(null);
settings.dispose();
}
});
panel.add(back);
settings.add(panel);
settings.setVisible(true);
}
}