title: Trouble storing input from jtextfield in arraylist for java GUI temperature guessing/conversion game
body: <p>Learned people of the internet. I'm currently working on an assignment for a first year programming class and, to be honest, programming is not my greatest skill. So any help with this small problem would be much appreciated.</p>
  
  <p>The program is essentially a number guessing game, that stores and sorts the guesses into an arraylist and displays, once you have guessed correctly, the average, the lowest guess, the index array of the correct guess, the average and the converted temperature in Fahrenheit. It is between 9 and 40 because the assignment specified 40 and the highest number on my student ID. Also the reason for the unnecessary amount of classes when I could simply put them into one is also the assignment specifications fault.</p>
  
  <p>The trouble I am having is storing the temperature guesses, whether correct or incorrect, in the arraylist. I believe I have initialised the arraylist correctly within my constructor but I am not sure how or where to capture the guesses from the jTextField. Once I figure that out I can incorporate the other methods I have written for the displayed results and be done with this assignment.</p>
  
  <p>Once again, I apologise for my general newbiness and any help would be extremely appreciated.</p>
  
  <pre><code>package TemperatureGuessApp;
  
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Random;
  import javax.swing.*;
  
  public class TemperatureFrame extends JFrame {
  
  public JFrame mainFrame;
  public JLabel prompt1, prompt2;
  public JTextField userInput;
  public JLabel comment;
  public JButton restart;
  public int randomTemperature;
  public int min = 9;
  public int max = 40;
  public int guessTemperature;
  public int sumTemperature;
  public double avgTemperature;
  public int lowestTemperature;
  public int convertedTemperature;
  public int indexTemperature;
  public Color background;
  
  public TemperatureFrame() {
  
      super("Temperature Guess/Conversion Application");
      prompt1 = new JLabel("Randomly generated temperature is between 9 and 40.");
      prompt2 = new JLabel("Write temperature (your guess) or -1 (for exit) and press enter key:");
      userInput = new JTextField(5);
      userInput.addActionListener(new GuessHandler());
      ArrayList&lt;Integer&gt; guesses = new ArrayList&lt;&gt;();
      comment = new JLabel("The results will be shown here.");
      restart = new JButton("Start Again - Generate A New Temperature");
      restart.addActionListener(
              new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      userInput.setText("");
                      comment.setText("The results will be shown here.");
                      RandomTemperature();
                      userInput.setEditable(true);
                  }
              });
  
      setLayout(new FlowLayout());
      background = Color.LIGHT_GRAY;
  
      add(prompt1);
      add(prompt2);
      add(userInput);
      add(comment);
      add(restart);
  
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(500, 150);
      setLocationRelativeTo(null);
      setVisible(true);
      setResizable(false);
  
      RandomTemperature();
      ConvertTemperature();
  }
  
  public void RandomTemperature() {
      Random random = new Random();
      randomTemperature = random.nextInt(max - min) + min;
  }
  public void SortTemperature() {   
  }
  public void FindLowestTemperature() {    
  }
  public void FindAverageTemperature() {    
  }
  public void FindIndexTemperature() {    
  }
  public void ConvertTemperature() {
      convertedTemperature = randomTemperature * 9 / 5 + 32;
  }
  
  class GuessHandler implements ActionListener {
  
      @ Override
      public void actionPerformed(ActionEvent e) {
          {
  
              guessTemperature = Integer.parseInt(userInput.getText());
              {   
  
                  if (guessTemperature &gt; randomTemperature) {
                      comment.setText("Temperature guessed is higher than the random temperature.");
                      userInput.setText("");
                      userInput.setEditable(true);
                  }
  
                  if (guessTemperature &lt; randomTemperature) {
                      comment.setText("Temperature guessed is lower than the random temperature.");
                      userInput.setText("");
                      userInput.setEditable(true);
                  }
  
                  if (guessTemperature == randomTemperature) {
                      comment.setText("Temperature guessed is equal to the random temperature.");
                      JOptionPane.showMessageDialog(null, "Temperature guessed is equal to the random temperature.\n\n1. Lowest temperature is:" + lowestTemperature + "\n2. Average temperature is:" + avgTemperature + "\n3. Array index of correctly guessed temperture is:" + indexTemperature + "\n4. Temperature in Farenheit is:" + convertedTemperature + "\n\nThank you for playing!");
                  } 
                  else if (guessTemperature == -1) {
                      System.exit(0);
                  }
              }
          }
      }
  }    
  }
  </code></pre>