That's a very beautiful operator and it's really frustrating to don't have it in Java.
if ("Nova Categoria" in textField1.getText()) {
textField1.setText("");
textField1.setForeground(Color.BLACK);
}
The bloody "==" does not give me what I want, and my Pythonic Mind can't give me the solution to this right now, because I want an "in".
How would you simulate an "in" operator in Java?
if (textField1.getText().contains("Nova Categoria"))
{
...
}
You can use contains method of String instead as follows:
if (textField1.getText().contains("Nova Categoria")) {
textField1.setText("");
textField1.setForeground(Color.BLACK);
}
Look here String#contains to know more about this method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With