-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWelcome.java
More file actions
64 lines (57 loc) · 2.18 KB
/
Welcome.java
File metadata and controls
64 lines (57 loc) · 2.18 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
import javax.swing.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Welcome {
//make a welcome frame for the snake game
public static void main(String[] args) {
JFrame welcome = new JFrame("Snake");
welcome.setSize(700, 700);
welcome.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon logo = new ImageIcon("logo.png");
welcome.setIconImage(logo.getImage());
welcome.setResizable(false);
JPanel panel = new JPanel();
panel.setBackground(Color.BLACK);
panel.setLayout(null);
JLabel title = new JLabel("Welcome to Snake!");
title.setFont(new Font("Comic Sans MS", Font.BOLD, 50));
title.setForeground(Color.WHITE);
title.setBounds(100, 100, 700, 100);
panel.add(title);
JButton cont = new JButton("Continue");
cont.setFont(new Font("Comic Sans MS", Font.BOLD, 30));
cont.setBounds(250, 300, 200, 100);
cont.setForeground(Color.WHITE);
cont.setBackground(Color.GREEN);
cont.setBorder(BorderFactory.createEtchedBorder());
cont.setFocusable(false);
cont.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Menu.main(args);
welcome.dispose();
}
});
panel.add(cont);
JButton exit = new JButton("Exit");
exit.setFont(new Font("Comic Sans MS", Font.BOLD, 30));
exit.setBounds(250, 500, 200, 100);
exit.setForeground(Color.WHITE);
exit.setBackground(Color.GREEN);
exit.setBorder(BorderFactory.createEtchedBorder());
exit.setFocusable(false);
exit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
welcome.dispose();
}
});
panel.add(exit);
welcome.add(panel);
welcome.setVisible(true);
welcome.setFocusable(true);
welcome.setLocationRelativeTo(null);
}
}