-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartScreen.java
More file actions
69 lines (57 loc) · 1.74 KB
/
Copy pathStartScreen.java
File metadata and controls
69 lines (57 loc) · 1.74 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
import java.awt.event.*;
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import javax.swing.*;
/**
* A menu that opens at the start of the game
*
* @Team MAGA
* @Author Gajun Young - 16440714
* @Author Royal Thomas - 16326926
* @Author Richard Otroshchenko - 16353416
*/
public class StartScreen extends JLabel implements ActionListener
{
JLabel screen;
JFrame frame;
JButton play,quit;
boolean letsPlay = false; //Becomes true when the play button is pressed
public void gameStart()
{
setLayout(new BorderLayout());
InputStream stream = getClass().getResourceAsStream("CluedoStart.jpg");
ImageIcon icon = null;
try {
icon = new ImageIcon(ImageIO.read(stream));
} catch (IOException e) {
System.out.println("Couldn't find image...." + e);
}
screen = new JLabel(icon);
screen.setVisible(true);
frame = new JFrame("Cluedo");
play=new JButton("PLAY");
quit= new JButton("QUIT");
frame.add(play, BorderLayout.CENTER);
frame.add(quit, BorderLayout.PAGE_END);
frame.add(screen, BorderLayout.PAGE_START);
play.addActionListener(this);
quit.addActionListener(this);
frame.setSize(600,370);
frame.setResizable(false);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==play){ //Closes the menu and starts the game up
letsPlay = true;
frame.dispose();
}
if(e.getSource()==quit) //Ends program if player chooses quit
{
System.exit(0);
}
}
}