As in the title, I want to display jOptionPane if there is no specific character in jTextField. Let's say that the symbol is "@".
I tried something like this:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String email = (String)txtEmail.getText();
if (!email.equals(email) && email.equals("@")){
jOptionPane1.showMessageDialog(null, "Please");
}
}
However, I cannot get this to work. I also tried using contains()and contentEquals(), but I do not know how to use it correctly, so I changed the code. A Google search also does not help, because I cannot find what I want. Please think of help. By the way, I use netbeans.
source
share