What I'm trying to do is parameterize accessing numbers of labels, knobs, etc. by creating arrays of references to them, then accessing those arrays using for loops (I did use ranged for loops, or whatever they're called in
Java, but I need the index for other purposes, so I changed them back). One example of code that's not working is:
Code: Select all
private VoltageLabel[] fieldLabel = { field1Label, field2Label, field3Label, field4Label,
field5Label, field6Label, field7Label, field8Label };
for(int iDex = 0; iDex < fieldLabel.length; ++iDex) {
fieldLabel[iDex].SetText(String.valueOf(iDex + 1));
}
where field1Label et al. are defined in the interface (i.e.,
Design Editor). Unfortunately, this doesn't work, nor does code that tries to compare against the array object references. My expertise is in
C++, and I've basically been learning
Java from the v 17 Language Spec (not the best way to do it, I know, but guaranteed to be "right"). Either there's something fundamental I don't understand about
Java, or
VM doesn't support this kind of usage. Maybe both.
I hope code like this can work, because I'm tired of typing in hordes of individual cases.