-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseFrame.java
More file actions
62 lines (54 loc) · 1.67 KB
/
Copy pathBaseFrame.java
File metadata and controls
62 lines (54 loc) · 1.67 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
import java.awt.Container;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
class BaseFrame extends JFrame implements KeyListener{
GameSelectorGUI selectorGUI;
Container c;
public BaseFrame(String name,GameSelectorGUI selector){
super(name);
c = getContentPane();
this.selectorGUI = selector;
}
public void contentAdd(JLabel j){
c.add(j);
}
public void contentPack(){
pack();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
if (!selectorGUI.Gaming)selectorGUI.PushUpAction();
break;
case KeyEvent.VK_DOWN:
if (!selectorGUI.Gaming)selectorGUI.PushDownAction();
break;
case KeyEvent.VK_W:
if (!selectorGUI.Gaming)selectorGUI.PushUpAction();
break;
case KeyEvent.VK_S:
if (!selectorGUI.Gaming)selectorGUI.PushDownAction();
break;
case KeyEvent.VK_SPACE:
if (!selectorGUI.Gaming)selectorGUI.OpenGameDetailWindow();
break;
case KeyEvent.VK_ENTER:
if (!selectorGUI.Gaming)selectorGUI.OpenGameDetailWindow();
break;
case KeyEvent.VK_ESCAPE:
if (!selectorGUI.Gaming) {
selectorGUI.RequestApplicationExit();
}
break;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}