-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindow.java
25 lines (19 loc) · 1.12 KB
/
Window.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
package Game.main;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
public class Window extends Canvas{
private static final long serialVersionUID = -1864215488270890922L;
public Window(int width, int height, String title, Game game){
JFrame frame = new JFrame(title); // Create New JFrame frame
frame.setPreferredSize(new Dimension(width, height)); // Set Frame Dimensions
frame.setMaximumSize(new Dimension(width, height));
frame.setMinimumSize(new Dimension(width, height));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Makes Sure That Top Right X Works
frame.setResizable(false); // Not Resizable
frame.setLocationRelativeTo(null); // Frame Positioned in Middle of Screen
frame.add(game); // Adding game Class Into Frame
frame.setVisible(true); // Can Actually See The Frame
game.start(); // Runs Game Start Method
}
}