forked from evantd/twidor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventHandler.java
174 lines (150 loc) · 4.47 KB
/
EventHandler.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
Twidor: the twiddler typing tutor.
Copyright (C) 2005 James Fusia
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
*/
/**
* CCG: Twidor- The Twiddler Tutor!
* <pre>
* EventHandler.java, the general event manager for Twidor.
*
* Revisions:
* 0.5 17 July 2003
* Completed Tutor
* 0.1 22 May 2003
* Created class EventHandler
* </pre>
* @author <a href="mailto:visyz@cc.gatech.edu">James Fusia</a>
* @version Version 0.5; 17 July 2003
*/
import java.awt.event.*;
import javax.swing.*;
public class EventHandler implements ActionListener, ItemListener, KeyListener, WindowListener, TwidorConstants {
/**
* internal variables
*/
private Twidor theTutor;
/**
* Default Constructor.
* Private. Don't want anybody to use it.
*/
private EventHandler () {
}// end EventHandler
/**
* Default Constructor.
* @param Twidor the tutor we manage
*/
public EventHandler (Twidor tutor) {
theTutor = tutor;
}// end EventHandler
/**
* Default accessor for internal variable
* @return Twidor my tutor
*/
public Twidor myTutor () {
return theTutor;
}// end myTutor ()
// ActionListener Dependencies
/**
* Invoked when an action is performed.
* @param ActionEvent to be interpreted
*/
public void actionPerformed (ActionEvent e) {
if (bDEBUG) System.out.println("EventHandler: Action Performed.");
myTutor().menuOption(e.getActionCommand());
}// end actionPerformed
// WindowListener Dependencies
/**
* Invoked when the window is set active.
* @param WindowEvent to be interpreted
*/
public void windowActivated (WindowEvent e) {
}// end windowActivated
/**
* Invoked when dispose is called on a window.
* @param WindowEvent to be interpreted
*/
public void windowClosed (WindowEvent e) {
myTutor().twidorQuit();
}// end windowClosed
/**
* Invoked when the window is closed from the menu.
* @param WindowEvent to be interpreted
*/
public void windowClosing (WindowEvent e) {
myTutor().twidorQuit();
}// end windowClosing
/**
* Invoked when a window is unselected.
* @param WindowEvent to be interpreted
*/
public void windowDeactivated (WindowEvent e) {
}// end windowDeactivated
/**
* Invoked when a window is un-minimized.
* @param WindowEvent to be interpreted
*/
public void windowDeiconified (WindowEvent e) {
}// end windowDeiconified
/**
* Invoked when a window is minimized.
* @param WindowEvent to be interpreted
*/
public void windowIconified (WindowEvent e) {
}// end windowIconified
/**
* Invoked when a window is first made visible.
* @param WindowEvent to be interpreted
*/
public void windowOpened (WindowEvent e) {
}// end windowOpened
// KeyListener Dependencies
/**
* Invoked when a key has been pressed.
* @param KeyEvent to be interpreted
*/
public void keyPressed (KeyEvent e) {
}// end keyPressed
/**
* Invoked when a key has been released.
* @param KeyEvent to be interpreted
*/
public void keyReleased (KeyEvent e) {
}// end keyReleased
/**
* Invoked when a key has been typed.
* @param KeyEvent to be interpreted
*/
public void keyTyped (KeyEvent e) {
if (bDEBUG) System.out.println("EventHandler: Key Pressed (" +
(int)e.getKeyChar() + ") " + e.getKeyChar());
myTutor().charTyped(String.valueOf(e.getKeyChar()),
System.currentTimeMillis());
}// end keyTyped
// ItemListener Dependencies
/**
* Invoked when an item has been selected or deselected
* @param ItemEvent to be interpreted
*/
public void itemStateChanged (ItemEvent e) {
if (bDEBUG) System.out.println("EventHandler: Menu Item changed state");
if (e.getItem() instanceof JCheckBoxMenuItem) {
myTutor().booleanOption(((JCheckBoxMenuItem)e.getItem()).getText(),
((JCheckBoxMenuItem)e.getItem()).getState());
}
else {
if (bDEBUG) System.out.println("EventHandler: Menu " + e.paramString());
}
}// end itemStateChanged
}// end class EventHandler