Quit program from JOptionpane

I am wondering if it is an if statement or a loop along side a pre determined string in order to make the exit(); function run specifically when a certain phrase is typed into the message box in
JOptionpane.showInputDialoge() i cannot seem to get it to work at all even with an if statement stating to run that action when “quit” has been typed into the input bar. I apologize if my wording it horrible.

1 Like

Make sure you’re checking via method equals(), and not via equality operator ==:

if ("quit".equals(input)) exit();

2 Likes