0

I'm making an interface for something and it is in fullscreen, so I can't click the X button to close it. In order to get around this I wanted to use esc as a close feature, this is my code for it

if(key == KeyEvent.VK_ESCAPE){
        frame.setVisible(false);
        stop();
        frame.dispose();
    }

When I press esc it closes, I can't see it active in my task screen, but when I go to task manager and then processes, it shows javaw.exe still being there and using memory. Is there anything I can do to fix this?

Edit: No this was not on how to exit a java program from within the code, it was about it staying loaded it the memory.

Urgaan
  • 23
  • 5
  • If `frame` is your main `JFrame`, consider setting the [closing behavior](https://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation(int)). – bradimus Aug 23 '16 at 16:38

1 Answers1

2

If you want to shut down the JVM, you can use System.exit(0);. Your code only disposes the interface, it doesn't stop the program.

Kayaman
  • 72,141
  • 5
  • 83
  • 121
  • Welp, I feel stupid... I didn't realise my stop feature had System.exit(1) instead of System.exit(0), thanks! – Urgaan Aug 23 '16 at 16:37