-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGamePlayer.java
More file actions
64 lines (54 loc) · 1.91 KB
/
GamePlayer.java
File metadata and controls
64 lines (54 loc) · 1.91 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
/*
* ============================================================================================
* GamePlayer.java : Extends JFrame and contains a panel where mouse move around on the screen.
*
* ============================================================================================
*/
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;
public class GamePlayer extends JFrame{
GamePanel panel2 = new GamePanel(10);
JButton button1 = new JButton("Try again"); //try again
JButton button2 = new JButton("Exit");//Exit the game
static JTextField textField = new JTextField(10);
public GamePlayer(){
JLabel label1 = new JLabel("elimination blocks");//eliminated blocks
JPanel panel = new JPanel(new BorderLayout());
JPanel panel3 = new JPanel(new BorderLayout());
textField.setEditable(false);
panel2.setLayout(new BorderLayout());
panel.setLayout(new FlowLayout());
panel.add(label1);
panel.add(textField);
panel.add(button1);
panel.add(button2);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(panel,BorderLayout.SOUTH);
this.getContentPane().add(panel2,BorderLayout.CENTER);
this.getContentPane().add(panel3,BorderLayout.SOUTH);
this.setSize(900,800);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("JavaGame");//Title
this.setVisible(true);
button1.setEnabled(true);
button2.setEnabled(true);
button1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
textField.setText("0");
panel2.beginNewGame();
}
});
button2.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
System.exit(0);
}
});
}
public static void main(String[] args) {
new GameClient();
}
}