Having a number of different textFields with different variable names: "txtFieldA1"; "txtFieldA2"; "txtFieldA3" ... etc. , in which different values are stored so that they will be put into an array.
is it possible make a for loop so that it the ide goes through all the textfields and assigns the values into the array by incrementing only the last character on the variable name string?
here's what i'm thinking about:
array[#] = Integer.parseInt(txtFieldA#.getText) //where '#' is the value I want to increment
No it's not possible in Java. Why not get rid of the variable names and place the "textfields" in an array to begin with? And what are text fields? Are they Swing JTextFields? AWT TextFields? SWT?
NetBeans standard palette generated Javax.swing.JTextFields
this part is in the GUI, so that the values from them are used in IFS for a fractal generator.
basically, each function looks like [ F = x*a + y*b + c ] where a,b,c are values taken from the text fields
I've got around 35 of these text fields and all have different names that differenciate by the last 2 characters : "txtInA0 / txtInB5 / etc".
the program assigns the values in the text fields to a matrix.... I want to know if there is a way to manipulate the code so that it compares the variable name to a string in which I change the last two characted to what I need.
That would be a bad design even if it were possible. To get a better design, you may want to show some code.
Originally Posted by Bogdan