So I have 44 buttons in my program, and for one of my methods I want to re-enable all of them. the buttons are easily named btn1, btn2, btn3...btn44. Is there a way I can use a for loop to enable all of them?
I would love to do something like this but I cannot find the resources necessary.
for(int i == 0, i < 44, i++){
btn<i>.setEnabled(true);
}
Without that I would have to go through each button
btn1.setEnabled(true);
btn2.setEnabled(true);
...
btn44.setEnabled(true);
I know this alternate method isn't that bad but I have similar areas in my code where a technique like the one I am looking for would be very useful. Thank you!
Listor similar? If not, how do you keep track of them?Collectionlike aList,ArrayListfor example. Then you can just callfor (Button b : buttons) { button.setEnabled(true); }ifbuttonsis the said list.44individual variables. Good that he can now remove the clutter using arrays and lists.