Adding rows of Jtextfields.
Hello, I'm having trouble adding a 8x2 array of jtextfields with "10" in each and have them in a 2d array[][] one for each column and I turn the string to a int and add the next jtextfield, I got one column to add the ints and if more then 8 it will go to the next column in a counter direction. I'm getting mixed up trying to go backwords and add the fields starting from myFields[1][7]. So myFields[0][0] through [0][7] then goes to [1][0] to [1][7] in counter clockwise direction, can't get from [1][7] back to [0][0].
[CODE]public void actionPerformed(ActionEvent e){
String currentField = myFields[0][0].getText();
int string1,string2, total;
string1 = Integer.parseInt(currentField);
if(string1 > 1)
for(int i = 1; i < string1; i++){
if(i < 8){
String nextField = myFields[0][i].getText();
string2 = Integer.parseInt(nextField);
total = string2 + 1;
String totalString = String.valueOf(total);
myFields[0][i].setText(totalString);
myFields[0][0].setText("1");
System.out.println("i<8");
}
else if(string1 == 1){
String nextField = myFields[0][1].getText();
string2 = Integer.parseInt(nextField);
total = string2 + 1;
String totalString = String.valueOf(total);
myFields[0][0].setText("0");
myFields[0][1].setText(totalString);
System.out.println("Last if");
}
}/CODE]
Last edited by Alaskan93; 04-27-2011 at 09:00 AM..
|