Sorry if this is a simple question but I'm not entirely sure how I check if a JTextField is not editable?
I know that to check if it is editable, you just use
JTextField.isEditable();
but how do I check if it is not?
Thanks
Accordingly to Java docs ( https://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#isEditable%28%29 ), isEditable:
Returns the boolean indicating whether this TextComponent is editable or not.
So, I guess you could just:
if (yourInstance.isEditable() == false) {
// Your action here
}
Or even:
if (!yourInstance.isEditable()) {
// Your action here
}
Use the logical complement operator (NOT):
if ( !textField.isEditable()){
.
.
.
}
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.