-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPopUp.java
More file actions
56 lines (46 loc) · 1.51 KB
/
PopUp.java
File metadata and controls
56 lines (46 loc) · 1.51 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
package org.millardps.InventoryManagement;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import javax.swing.JPanel;
public class PopUp {
private MyDispatcher m = new MyDispatcher();
private KeyboardFocusManager manager;
private BI background;
public PopUp(int width, int height, int sx, int sy){
background = new BI(width, height, sx, sy, false, false);
background.fillCanvas(Color.GRAY.getRGB());
}
public BI getBackground(){
return background;
}
public void setQuestion(String s){
background.addName(s);
}
public void drawPopup(Graphics2D g2){
g2.drawImage(background.getBuffImage(), background.getSX(), background.getSY(), null);
}
public void FocusKeys(){
manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
manager.addKeyEventDispatcher(m);
}
public void UnfocusKeys(){
manager.removeKeyEventDispatcher(m);
}
private class MyDispatcher implements KeyEventDispatcher {
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
// if (e.getID() == KeyEvent.KEY_PRESSED) {
// System.out.println("tester");
// } else if (e.getID() == KeyEvent.KEY_RELEASED) {
// System.out.println("2test2");
// }
if (e.getID() == KeyEvent.KEY_TYPED) {
System.out.println("Key Typed: " + e.getKeyChar());
}
return false;
}
}
}