-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindow.java
More file actions
26 lines (22 loc) · 739 Bytes
/
Window.java
File metadata and controls
26 lines (22 loc) · 739 Bytes
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
import java.awt.Dimension;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
public class Window {
public Window(int width, int height, String title, SnakeGame game) {
game.setPreferredSize(new Dimension(width, height));
game.setMaximumSize(new Dimension(width, height));
game.setMinimumSize(new Dimension(width, height));
JFrame frame = new JFrame(title);
frame.add(game);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setFocusable(true);
frame.toFront();
frame.requestFocus();
System.out.println("Game Started");
}
}