So I need to make a Java program that can read in user input in text-fields. I was able to set up the array of text fields but reading in the input and storing the data in a new array is troubling me greatly. I made a listener for the buttons and I just need to figure out how to store the information entered in the textField array into the grade array so I can perform calculations on the grades. I am new to this site and appreciate the help
//an Array for test scores and one to hold the input grades
JTextField[] testScores;
double[] grade;
/**
Constructor
*/
public StatisticsCalculator()
{
//Display a Title
setTitle("JP Stearns");
//Specify the action for the Close button
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create a Border Layout
setLayout(new BorderLayout());
//Create the Custom Panels
buildScoresPanel();
buildStatisticsPanel();
//Build the Button Panel
buildButtonPanel();
//Add the Components to the content pane
add(scoresPanel, BorderLayout.NORTH);
add(statisticsPanel, BorderLayout.CENTER);
add(buttonPanel, BorderLayout.SOUTH);
//Pack the contents of the Window to display it.
pack();
setVisible(true);
}
//Create a GridLayout manger
//with 1 row 4 columns.
scoresPanel.setLayout(new GridLayout(1,4));
//Create 4 text fields using an array
testScores = new JTextField[4];
for (int index = 0; index < testScores.length; index++)
{
testScores[index] = new JTextField(4);
scoresPanel.add(testScores[index]);
}
//Border the panel
scoresPanel.setBorder(BorderFactory.createTitledBorder("Test Scores"));
private void buildScoresPanel()
{
//Create a panel for the test scores
scoresPanel = new JPanel();
//Create a GridLayout manger
//with 1 row 4 columns.
scoresPanel.setLayout(new GridLayout(1,4));
//Create 4 text fields using an array
testScores = new JTextField[4];
for (int index = 0; index < testScores.length; index++)
{
testScores[index] = new JTextField(4);
scoresPanel.add(testScores[index]);
}
//Border the panel.v
scoresPanel.setBorder(BorderFactory.createTitledBorder("Test Scores"));
}