-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFrame.java
75 lines (66 loc) · 1.82 KB
/
Frame.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* This Class <code>Frame</code> operates on ruling the frame's display.
*
* @author lerouxdu
* @version 0.1
*/
public class Frame extends javax.swing.JFrame
{
/**
* Constructor <code>Frame</code>.
*/
public Frame()
{
super();
final int HEIGHT = 780;
final int WIDTH = 1100;
java.awt.Dimension dim = new java.awt.Dimension(WIDTH, HEIGHT);
this.setPreferredSize(dim);
this.setMinimumSize(dim);
this.setMaximumSize(dim);
this.setResizable(false);
this.setUndecorated(true);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
this.initComponents();
this.handler();
this.pack();
}
/**
* Initializes the graphic components within the frame.
*
* @see push
*/
private void initComponents()
{
this.push(new Menu(this));
}
/**
* Sets an adapter that binds ESCAPE to dispose the frame.
*/
private void handler()
{
this.getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(javax.swing.KeyStroke.getKeyStroke(
java.awt.event.KeyEvent.VK_ESCAPE, 0), "Cancel");
this.getRootPane().getActionMap().put("Cancel", new javax.swing.AbstractAction()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
dispose();
System.exit(0);
}
});
}
/**
* Add the component to the frame.
*
* @param p the component to add
*/
public void push(javax.swing.JComponent p)
{
this.getContentPane().removeAll();
this.add(p, java.awt.BorderLayout.CENTER);
this.revalidate();
this.getContentPane().repaint();
}
}