-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMenu.java
80 lines (62 loc) · 2.32 KB
/
Menu.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Menu implements ActionListener {
JFrame menu = new JFrame("Game Of Words");
JLabel label = new JLabel();
JButton playgame = new JButton("Play");
JButton btn_highscore = new JButton("High Score");
JButton btn_about = new JButton("About");
JButton btn_exit = new JButton("Exit");
Menu(){
menu.setVisible(true);
menu.setSize(1000,600);
menu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
menu.setResizable(false);
menu.add(label);
ImageIcon icon = new ImageIcon(this.getClass().getResource("/img/GOB.png"));
menu.setIconImage(icon.getImage());
ImageIcon image1 = new ImageIcon(this.getClass().getResource("./img/menu.png"));
label.setIcon(image1);
label.setSize(1000,600);
label.add(playgame);
label.add(btn_highscore);
label.add(btn_about);
label.add(btn_exit);
playgame.setBounds(450,250,130,35);
playgame.addActionListener(this);
btn_highscore.setBounds(450,300,130,35);
btn_highscore.addActionListener(this);
btn_about.setBounds(450,350,130,35);
btn_about.addActionListener(this);
btn_exit.setBounds(450,400,130,35);
btn_exit.addActionListener(this);
playgame.setFont(new Font("SERIF", Font.BOLD, 20));
btn_highscore.setFont(new Font("SERIF", Font.BOLD, 20));
btn_about.setFont(new Font("SERIF", Font.BOLD, 20));
btn_exit.setFont(new Font("SERIF", Font.BOLD, 20));
playgame.setCursor(new Cursor(Cursor.HAND_CURSOR));
btn_highscore.setCursor(new Cursor(Cursor.HAND_CURSOR));
btn_about.setCursor(new Cursor(Cursor.HAND_CURSOR));
btn_exit.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==playgame){
menu.dispose();
new Level();
}
if(e.getSource() == btn_highscore){
menu.dispose();
new HighScorePage();
}
if(e.getSource()==btn_about){
menu.dispose();
new About();
}
if(e.getSource()==btn_exit){
System.exit(0);
}
}
}