In the following code, it asks for the name to be filled in, but if you do not type anything, and I click cancel it returns me a message (The name that you entered was Null).
My question is how do I to click on cancel it directly close the application or appear another message, not appear "null".
Here's the code part:
mensagem.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String nome;
nome = JOptionPane.showInputDialog("Qual seu nome?");
JOptionPane.showMessageDialog(janela, "O nome que informou foi:\n"+nome);
}
});