for (int x=0; x<3; ++x) { String s = textField[x].getText(); g.drawString(s, 75, 110 + x*15); avg[x] = Integer.parseInt(s); }