title: Stumped on making JButton work
body: <p>I'm creating a simple GPA calculator in Java. It worked using JOptionPane, but I want the user to be able to answer all questions in one window. So, I am experimenting with JPanel.</p>
  
  <p>When the user hits the "Submit" button, I want the program to calculate the GPA. I'm having trouble figuring how to incorporate the event handler. </p>
  
  <p>Here is the code: </p>
  
  <pre><code>import java.math.RoundingMode;
  import java.text.DecimalFormat; format.
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.*;
  import javax.swing.event.*; 
  
  
  public class MyGpaCalc extends JFrame {
  
  public static void createGuiWindow() {
  
  
  JFrame frame = new JFrame("GPA Calculator"); 
  frame.setSize(300,250); 
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
  
  
  JPanel panel = new JPanel();
  
  JLabel aGradesLabel = new JLabel("# credits earned with A grade: ");
  JTextField aGradesText = new JTextField(3); 
  JLabel bGradesLabel = new JLabel("# credits earned with B grade: ");
  JTextField bGradesText = new JTextField(3);
  JLabel cGradesLabel = new JLabel("# credits earned with C grade: ");
  JTextField cGradesText = new JTextField(3); 
  JLabel dGradesLabel = new JLabel("# credits earned with D grade: ");    
  JTextField dGradesText = new JTextField(3);
  JLabel fGradesLabel = new JLabel("# credits earned with F grade: ");
  JTextField fGradesText = new JTextField(3); 
  
  JButton submit = new JButton("Submit");
  
  panel.add(aGradesLabel);
  panel.add(aGradesText);
  panel.add(bGradesLabel);
  panel.add(bGradesText);
  panel.add(cGradesLabel);
  panel.add(cGradesText);
  panel.add(dGradesLabel);
  panel.add(dGradesText);
  panel.add(fGradesLabel);
  panel.add(fGradesText);
  
  frame.getContentPane().add(panel); 
  frame.setVisible(true); 
  
  }
  
  public static void main(String[] args) {
  
  createGuiWindow(); 
  
  
  DecimalFormat df = new  DecimalFormat("0.00");
  df.setRoundingMode(RoundingMode.FLOOR);
  
  
  double aGrades = Double.parseDouble(aGradesText.getText());
  double bGrades = Double.parseDouble(bGradesText.getText());
  double cGrades = Double.parseDouble(cGradesText.getText());
  double dGrades = Double.parseDouble(dGradesText.getText());
  double fGrades = Double.parseDouble(fGradesText.getText());
  
  
  double totalCredits = aGrades + bGrades + cGrades + dGrades + fGrades;
  
  double gradePoints = (aGrades * 4) + (bGrades * 3) + (cGrades * 2) + (dGrades * 1) + (fGrades * 0);
  
  double sum = gradePoints / totalCredits;
  
  
  
  
  System.exit(0); 
  }
  
  
  }
  </code></pre>