Close a Java program at any time

0

Java doubt

The question I have is about how a program in Java could end at any moment of the execution by writing a specific word.

    
asked by Partyhard 11.10.2018 в 12:23
source

2 answers

5

With System.exit(0); close the execution

    
answered by 11.10.2018 / 12:28
source
1

Partyhard, well, here is an example of how you can guide yourself:)

for example: in a jframe it generates a jtextfield and a jbutton: and in the event click or action of the jbutton place this:

if(jtextfield.getText().equals("SALIR")){
jframe.dispose();
}

and each time you click on the button, that code will get the text of the jtextfield and match it with what you wrote in the if evaluation. You can also do it with the equalsIgnoreCase.

Greetings: I hope I helped you!

    
answered by 12.10.2018 в 21:30