I've created the following function in order to close any pop up Stage in my program:
public void escapeKeyPressed(final KeyEvent keyEvent , Stage diolog) { if (keyEvent.getCode() == KeyCode.ESCAPE) { diolog.close(); } } Then, I have a clickable image where can be clicked and a form will pop up :
The problem is when I call the function I get error for the first argument . Here is how I call it ;)
escapeKeyPressed( KeyCode.ESCAPE ,dialog ); Does any body know how can I fix that ?