Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Thank you! Note: In the project, you must have the following two java programs and you may create more java programs if you need. CourseApp.java

Thank you!

Note:

In the project, you must have the following two java programs and you may create more java programs if you need.

CourseApp.java: is the JFrame class, contains the GUI, and has the main method.

CourseData.java: reads data from and writes data into a text file, course.txt, and provides necessary results for other class or classes to use.

Make sure that when accessing the text file, your program uses just the file name without explicitly providing a path (so called relative path. Refer to chapter 18 for an example of the relative path). (4 points)

course.txt is given. However, when testing your program, my course.txt will have different content but follow the same format as the given course.txt. So you do not hard code in your program.

The given course.txt includes:

ACC 207Alex Gonzalez ACC 207Jack Williams ACC 207Jane Brown ACC 207Jian Chen ACC 207Lily Makki ACC 207Eduardo Lopez 

Requirements in summary:

develop a Java GUI application when the program starts, it reads course and student information from a given text file, course.txt, and shows their contents in the ComboBox and JList,

add a new student to a course,

delete one or more selected students from a course,

add a new course and,

delete a course and all its students

Requirements in details:

UI Construction and data population

After the program starts, it reads all course and student information from course.txt. In this file, each row consists of a course number and a student name, separated by . The program populates a ComboBox with distinct courses, and displays student names for a course in a JList. The JList allows multiple interval selections. Students in a course may have the same name. Fig.1 is the initial UI of the program.

image text in transcribed

Fig. 1 Initial GUI of the program

Descriptions for four function buttons are as follows.

2)Add Student

Entering a new student name in the TextField and clicking the Add Student button will add the student to the JList and also to the course.txt file. Then the entry in the text field is cleared.

Instead of using mouse to click the button, pressing Alt + a triggers Add Student button click.

Fig. 2 shows a new student, John Smith, is added to the list.

image text in transcribed

Fig. 2 A new student, John Smith, is added to JList

If clicking Add Student button without entering anything in the text field, a dialog window shows the following error message. Hint: the dialog window is generated by JOptionPane.showMessageDialog().

image text in transcribed

3)Delete Student

The JList allows multiple interval selection. When clicking Delete Student button, a confirmation dialog displays names of students to be deleted and asks for confirmation. Hint: the dialog window is generated by JOptionPane.showConfirmDialog().

image text in transcribed

If clicking the Yes button, all selected students will be removed from the JList and also from the course.txt file. If clicking No, the selected students will not be deleted.

Pressing Alt + d triggers the Delete Student button click.

If clicking Delete Student button without selecting any student in the list, the following dialog window displays an error message.

image text in transcribed

4)Add Course

Entering a new course name in the TextField and then clicking the Add Course button will add the course to the ComboBox and also to the course.txt file. Then the textfield is cleared.

Fig. 3 shows a new course, CIS 305, is added.

image text in transcribed

Fig. 3 A new course, CIS 305, is added

A new entry in the course.txt is like the following before any student is added:

CIS 305

If a student, John Smith, is added to CIS 305 afterwards, the course.txt will have a row like the following:

CIS 305John Smith

image text in transcribed If clicking Add Course button without entering anything in the text field, a dialog window shows the following error message:

5)Delete Course

Clicking Delete Course button will pop up a confirmation dialog asking to confirm.

image text in transcribed

If click Yes, the program will delete the selected course and all its students from the UI. In the course.txt all records for this course and its students will be removed as well. Then the program reads the updated course.txt and displays another course and its student list.

If all courses are deleted, the ComboBox and JList become blank as shown in Fig. 4.

image text in transcribed

Student Course Application Courses: C 207 Delete Course Entry to add: Add Course Student List: Alx Gonzales Add Student Jack Williams Jane Brown Jian Chen Lily Makki Eduardo Lopez Delete Student Student Course Application Courses: C 207 Delete Course Entry to add: Add Course Student List: Alx Gonzales Add Student Jack Williams Jane Brown Jian Chen Lily Makki Eduardo Lopez Delete Student

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

Draw a labelled diagram of the Dicot stem.

Answered: 1 week ago