if (exitOnClose) {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//create the event handler for key preview functionality
keyEventListener = new AWTEventListener() {
public void eventDispatched(AWTEvent aWTEvent) {
if (aWTEvent instanceof KeyEvent) {
KeyEvent evt = (KeyEvent)aWTEvent;
for (KeyListener kl : getKeyListeners()) {
int id = aWTEvent.getID();
switch (id) {
case KeyEvent.KEY_PRESSED:
kl.keyPressed(evt);
break;
case KeyEvent.KEY_RELEASED:
kl.keyReleased(evt);
break;
case KeyEvent.KEY_TYPED:
kl.keyTyped(evt);
break;
default:
System.err.println("Unhandled Key ID: " + id);
}
}
}
}
};
idleTimer = new Timer(100, new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
setIdle(true);
}
});
//create the event handler for key preview functionality
idleListener = new AWTEventListener() {
public void eventDispatched(AWTEvent aWTEvent) {
//reset the timer
idleTimer.stop();
//if the user is idle, then change to not idle
if (isIdle()) {