Question: Purpose: To be able to Do CRUD operations against object arrays of different types. Sort with the comparator class Achieve this overall goal from the
Purpose: To be able to Do CRUD operations against object arrays of different types. Sort with the comparator class Achieve this overall goal from the course syllabus: "After completing this, you should be able to create a Java application with a user interface in which the user can add to, delete, modify, search and list data.
This is created with java.
It is important that the user receives a response as to what happened after each button press, so certain the result of these in a text area.
4. Make a GUI program, see example below, with JFrame and suitable Swing components where you can:
a. Add a CD discs to an array of CD objects.
b. Change information about CD based on CD ID
c. Remove CD based on CD ID
d. Search by music genre and list all CDs for the searched genre.
e. Search for the artist and list all CDs for the searched artist.
i. Talk about how many records this particular artist has made
f. List data about all CDs in the array of CD objects
g. A sort button that sorts by artist name. And one on production year. Use Arrays.sort and a Comparator class.
My code so far:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class CDManager {
private JFrame frame;
private JTextField idField;
private JTextField artistField;
private JTextField genreField;
private JTextField yearField;
private JButton addButton;
private JButton updateButton;
private JButton deleteButton;
private JButton searchGenreButton;
private JButton searchArtistButton;
private JButton listAllButton;
private JButton sortArtistButton;
private JButton sortYearButton;
private JTextArea textArea;
private CD[] cds;
public CDManager() {
// Initialize the GUI components
frame = new JFrame();
idField = new JTextField();
artistField = new JTextField();
genreField = new JTextField();
yearField = new JTextField();
addButton = new JButton("Add CD");
updateButton = new JButton("Update CD");
deleteButton = new JButton("Delete CD");
searchGenreButton = new JButton("Search by Genre");
searchArtistButton = new JButton("Search by Artist");
listAllButton = new JButton("List All CDs");
sortArtistButton = new JButton("Sort by Artist");
sortYearButton = new JButton("Sort by Year");
textArea = new JTextArea();
// Initialize the array of CDs
cds = new CD[0];
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
