This is my function which displays JOptionPane with Warning message in case of self-intersection.
The problem is that after JOptionPane is closed my applet does not gain the focus again, so it cannot capture ESC key pressed and also the applet is not redrawn properly.