do not need code. just explain the steps in getting started with this The Drivin
ID: 3532910 • Letter: D
Question
do not need code. just explain the steps in getting started with this
The Driving Academy Program
The purpose of this lab is to give you a chance to use some of the data stream tools we have been discussing in a simple application. The assignment is to write a driving academy application that allows a user to manipulate the records of students of a driving academy.
Your program will present a GUI interface which allows the user to specify student id, student name, and instructor name. It also allows the user to record grades for the midterm, final, and driving test. It displays the current overall average grade for the student. It provides a place for instructor comments to be entered and displayed. Finally, it provides buttons that permit student records to be added, fetched, updated, and deleted. There is also a button to reset the fields of the GUI to their initial condition, and there is a place where the status of each requested operation is displayed. The GUI for this program is displayed below.
You will be given the graphical user interface class for this assignment. Your job is to add the necessary event handling and data management classes to make this application work and meet the requirements as detailed below. You are NOT allowed to change the GUI.
Required program elements:
NOTE: This is a VERY common way that real applications are structured. The user interface is designed separately from the data management aspect of the application. In our program, we have the GUI class that presents the user interface. We have the data manager class which understands what needs to be done to add, update, fetch, and delete student records using objects and files. And we have the event handler class as an inner class that can access the GUI components AND make method calls to the data manager object. Nothing in the GUI class has any knowledge of what the data manager is doing internally. Nothing in the data manage has any knowledge of what is going on in the GUI.
Explanation / Answer
package driving;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class UserInterface extends JFrame
{
private StudentDataManager dataManager = new StudentDataManager();
private JButton add, fetch, update, delete, reset;
private JLabel sidl, namel, instl;
private JTextField sidtf, nametf, insttf;
private JLabel commentl;
private JTextArea commentta;
private JScrollPane commentsp;
private JLabel midterml, finall, drivingl, overalll;
private JTextField midtermtf, finaltf, drivingtf, overalltf;
private JLabel statusl;
private JTextField statustf;
public UserInterface()
{
super("Rick's Driving Academy");
buildTop();
buildBottom();
buildRight();
buildLeft();
pack();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
private void buildTop()
{
Dimension dim = new Dimension(60,25);
JPanel tp = new JPanel();
sidl = new JLabel("Student ID");
namel = new JLabel("St. Name");
instl = new JLabel("Instructor");
sidtf = new JTextField(8);
nametf = new JTextField(8);
insttf = new JTextField(8);
sidl.setPreferredSize(dim);
namel.setPreferredSize(dim);
instl.setPreferredSize(dim);
sidl.setHorizontalAlignment(SwingConstants.RIGHT);
namel.setHorizontalAlignment(SwingConstants.RIGHT);
instl.setHorizontalAlignment(SwingConstants.RIGHT);
tp.add(sidl);
tp.add(sidtf);
tp.add(namel);
tp.add(nametf);
tp.add(instl);
tp.add(insttf);
add(tp, BorderLayout.NORTH);
}
private void buildBottom()
{
Dimension dim = new Dimension(90,25);
JPanel bp1 = new JPanel();
add = new JButton("Add");
fetch = new JButton("Fetch");
update = new JButton("Update");
delete = new JButton("Delete");
reset = new JButton("Reset");
add.setPreferredSize(dim);
fetch.setPreferredSize(dim);
update.setPreferredSize(dim);
delete.setPreferredSize(dim);
reset.setPreferredSize(dim);
bp1.add(add);
bp1.add(fetch);
bp1.add(update);
bp1.add(delete);
bp1.add(reset);
JPanel bp2 = new JPanel();
statusl = new JLabel("Command Status:");
statustf = new JTextField(32);
statustf.setEditable(false);
bp2.add(statusl);
bp2.add(statustf);
JPanel bp3 = new JPanel(new GridLayout(2,1));
bp3.add(bp1);
bp3.add(bp2);
add(bp3, BorderLayout.SOUTH);
}
private void buildRight()
{
JPanel rp = new JPanel();
rp.setLayout(new BorderLayout());
rp.setBorder(BorderFactory.createEmptyBorder(0,10,0,10));
commentl = new JLabel("Instructor Comments");
commentl.setHorizontalAlignment(SwingConstants.CENTER);
rp.add(commentl, BorderLayout.NORTH);
commentta = new JTextArea(6,30);
commentsp = new JScrollPane(commentta);
rp.add(commentsp, BorderLayout.CENTER);
add(rp, BorderLayout.CENTER);
}
private void buildLeft()
{
JPanel lp = new JPanel();
lp.setLayout(new GridLayout(4,2,5,5));
lp.setBorder(BorderFactory.createEmptyBorder(0,10,0,0));
midterml = new JLabel("Midterm");
finall = new JLabel("Final");
drivingl = new JLabel("Driving");
overalll = new JLabel("Overall");
midtermtf = new JTextField("0",3);
finaltf = new JTextField("0",3);
drivingtf = new JTextField("0",3);
overalltf = new JTextField("0",3);
overalltf.setEditable(false);
lp.add(midterml);
lp.add(midtermtf);
lp.add(finall);
lp.add(finaltf);
lp.add(drivingl);
lp.add(drivingtf);
lp.add(overalll);
lp.add(overalltf);
add(lp, BorderLayout.WEST);
}
public static void main(String[] args)
{
UserInterface myApp = new UserInterface();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.