import javax.swing.*; // Needed for swing classes
import java.awt.event.*; // Needed for the action listener
import java.io.*; // Needed for the file and IOException
import java.util.Scanner; // Needed for the scanner class
import java.util.List; // Needed for the arraylist
import java.util.Arrays; // Needed for the arraylict class
/**
This program creates a grade calculator that lets you enter
multiple students name and three grades of each student. When
calculate button is clicked, the results are displayed in
displayed in either alphabetical or numerical.
*/
public class GradeProgram extends JFrame
{
private JPanel panel; // To reference the a panel
private JButton saveB, nextB, prevB, calcGrade; // Creates the Buttons
private JPanel buttonPanel; // To reference the panel where all the buttons go
private final int WINDOW_WIDTH = 350;
private final int WINDOW_HEIGHT = 450;
/**
Constructor
*/
public GradeProgram()
{
// Set the window title.
setTitle("Grade Program");
// Set the size of window.
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
// Specify what happens when the close button is clicked.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Build the panel and add it to the frame.
buildButtonPanel();
// Add the panel to the frame's content pane.
add(panel);
// packs all the panels togather
pack();
// Display the window.
setVisible(true);
}
/**
The builds the buttons for the panel.
*/
private void buildButtonPanel()
{
prevB = new JButton("Prev");// Adds the text prev to the prevB
calcGrade = new JButton("Calculate");// Adds the text Calc Grade to the calcGrade
nextB = new JButton("Next");// Adds the text Next to the nextB
saveB = new JButton("Save");// Adds the text Save to the saveB
calcGrade.addActionListener(new calcGradeListener());// Adds an ActionListener to the button
prevB.addActionListener(new prevBListener());// Adds an ActionListener to the button
nextB.addActionListener(new nextBListener());// Adds an ActionListener to the button
saveB.addActionListener(new saveBListener());// Adds an ActionListener to the button
panel = new JPanel();
buttonPanel.add(prevB); // Adds the prevB to the panel
buttonPanel.add(saveB); // Adds the saveB to the panel
buttonPanel.add(nextB); // Adds the nextB to the panel
buttonPanel.add(calcGrade);// Adds the calcGrade to the panel
}
/**
calcGradeListener is an action listener clas for the Calculate button.
*/
private class calcGradeListener implements ActionListener
{
/**
The actionPerformed method executes when the user
clicks on the Calculate button.
@param e The event object.
*/
/**
CalcButtonListener is an action listener clas for the Calculate button.
*/
}
private class prevBListener implements ActionListener
{
/**
The actionPerformed method executes when the user
clicks on the prevB button.
@param e The event object.
*/
}
private class nextBListener implements ActionListener
{
/**
The actionPerformed method executes when the user
clicks on the next button.
@param e The event object.
*/
}
private class saveBListener implements ActionListener
{
/**
The actionPerformed method executes when the user
clicks on the saveB button.
@param e The event object.
*/
}
public void actionPerformed(ActionEvent e)
{
}
}
ERRORS
----jGRASP exec: javac -g GradeProgram.java
GradeProgram.java:82: GradeProgram.calcGradeListener is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
private class calcGradeListener implements ActionListener
^
GradeProgram.java:95: GradeProgram.prevBListener is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
private class prevBListener implements ActionListener
^
GradeProgram.java:104: GradeProgram.nextBListener is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
private class nextBListener implements ActionListener
^
GradeProgram.java:113: GradeProgram.saveBListener is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
private class saveBListener implements ActionListener
^
4 errors