I have multiple text fields which I need to enabled or disabled at once using Java Swing. Is that possible?
If all the JTextFields are on a single container, you could do :
for (Component c : container.getComponents()) {
if (c instanceof JTextField) {
c.setEnabled(false);
}
}
if you put them all in a linked list / array list you could have a method to loop though it and enable / disable. This is probably the easiest way
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