-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWindow.java
56 lines (47 loc) · 1.51 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
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
package testSQuares2;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
/**
* Creates frame and set its properties.
*
* @author VPC
*/
public class Window extends JFrame{
private Window()
{
// Sets the title for this frame.
this.setTitle("Game title");
// Sets size of the frame.
if(false) // Full screen mode
{
// Disables decorations for this frame.
this.setUndecorated(true);
// Puts the frame to full screen.
this.setExtendedState(this.MAXIMIZED_BOTH);
}
else // Window mode
{
// Size of the frame.
this.setSize(1280, 800);
// Puts frame to center of the screen.
this.setLocationRelativeTo(null);
// So that frame cannot be resizable by the user.
this.setResizable(false);
}
// Exit the application when user close frame.
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Creates the instance of the Framework.java that extends the Canvas.java and puts it on the frame.
this.setContentPane(new Framework());
this.setVisible(true);
}
public static void main(String[] args)
{
// Use the event dispatch thread to build the UI for thread-safety.
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Window();
}
});
}
}