I have a program where I am using several hundred JToggleButtons. Their names differ only slightly by numbers (e.g. jToggleButton1, jToggleButton2, jToggleButton3,…)
Is there a way that I can use a for loop when doing the same thing to multiple buttons?
For instance, if I want to programmatically change the states of several buttons, could I loop through them, changing the ending number of the name each time?
I have a program where I am using several hundred JToggleButtons. Their names differ
Share
You could try to put them all in an array or
ArrayListand use aforeachloop.