-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGameOne.java
More file actions
73 lines (59 loc) · 1.62 KB
/
GameOne.java
File metadata and controls
73 lines (59 loc) · 1.62 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
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
// this is just a game launcher class
public class GameOne extends JFrame {
static final int BOARD_WIDTH = 500;
static final int BOARD_HEIGHT = 500;
/**
* Launch the application.
*/
public static void main(String[] args) {
GameOne frame = new GameOne();
frame.setVisible(true);
}
private void askForClose(){
int choice = JOptionPane.showConfirmDialog(this,
"Do u really want to close this window"
,"My Gaming",JOptionPane.YES_NO_OPTION);
if(choice == JOptionPane.YES_OPTION){
this.setVisible(false);
this.dispose();
}
else
if(choice == JOptionPane.NO_OPTION){
return;
}
}
/**
* Create the frame.
*/
public GameOne() {
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
askForClose();
}
});
this.setTitle("Sky War - 2017");
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(BOARD_WIDTH,BOARD_HEIGHT);
this.setLocationRelativeTo(null);
//setBounds(100, 100, 450, 300);
this.getContentPane().setLayout(null);
Board board = new Board();
this.getContentPane().add(board);
}
}