import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class displayFullScreen extends JFrame {
private JLabel alarmMessage = new JLabel(
You are not closing your your frame at esc key. You are just setting its default close operation so you must write
System.exit(0);
or
dispose();
instead of
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
If you don't want to exit the application then use setVisible(false)
.
Tip:
VK_ESCAPE
is static filed of KeyEvent
class so instead of ke.VK_ESCAPE
you can write KeyEvent.VK_ESCAPE
.