Hey Fellas,
I created 10 JTextFields using and ArrayLists:
ArrayList<JTextField> textFArray = new ArrayList<>();
textFArray.add(new JTextField());
gbc.gridx = 1;
for (int i = 0; i < 10; i++) {
gbc.gridy++;
add(textFArray.get(i), gbc);
textFArray.add(new JTextField(i));
}
What I need to do:
I need to get the values of what ever the user puts into the JTextField(s) and total the inputs and assign them to a variable. This is what I have so far:
double totalTemp;
for(JTextField temps: textFArray){
//System.out.println(temps.getText());
totalTemp = Integer.parseInt(temps.getText());
}
I know the code snippet above doesnt work properly. If you uncomment the the one line, it can display the inputs. But the problem is adding them.
Would it be possible to put them into an ArrayList? This would be great as it would give me the ability to perform comparisons as well.