I have all of my program working except the following buttons (add, modify, delete, save, search) which I have the buttons, but turned off in my program so it will still compile/run until I get the button functionality fixed. To be honest, I have no clue on what code needs to make them work as required. I am strictly a beginner and it has taken many many sleepless nights just to get to this point. Any help would be very much appreciated. :) The following is what I need to accomplish, followed by my section of code (as not to overwhelm you with my whole program):
Modify the Inventory Program to include an Add button, a Delete button, and a Modify
button on the GUI. These buttons should allow the user to perform the corresponding
actions on the item name, the number of units in stock, and the price of each unit. An
item added to the inventory should have an item number one more than the previous last
item.
• Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
• Use exception handling to create the directory and file if necessary.
• Add a search button to the GUI that allows the user to search for an item in the inventory
by the product name. If the product is not found, the GUI should display an appropriate
message. If the product is found, the GUI should display that product’s information in the
GUI.
// I NEED HELP WITH THIS SECTION. HAVE NO CLUE ON WHAT CODE WILL MAKE BUTTONS WORK AS REQUESTED
// private JButton addButton = new JButton(addAction);
//private Action lastAction = new AbstractAction("Add") {
// public void actionPerformed(ActionEvent evt) {
//index = ProductInventory.getSize() - 1;
// repaint();
// }
// };
// private JButton modifyButton = new JButton(modifyAction);
// private Action lastAction = new AbstractAction("Modify") {
// public void actionPerformed(ActionEvent evt) {
// index = ProductInventory.getSize() - 1;
// repaint();
// }
// };
//private JButton deleteButton = new JButton(deleteAction);
//private Action lastAction = new AbstractAction("Delete") {
// public void actionPerformed(ActionEvent evt) {
// index = ProductInventory.getSize() - 1;
// repaint();
// }
//};
// private JButton saveButton = new JButton(saveAction);
// private Action lastAction = new AbstractAction("Save") {
// public void actionPerformed(ActionEvent evt) {
// index = ProductInventory.getSize() - 1;
// repaint();
// }
//};
//private JButton searchButton = new JButton(searchAction);
//private Action lastAction = new AbstractAction("Search") {
// public void actionPerformed(ActionEvent evt) {
// index = ProductInventory.getSize() - 1;
// repaint();
// }
//};