I seem to be hitting road block after road block. I had my application working and I made a new class called AddMain and a deleted the other public main class so I can begin testing the app as a whole.
Now the main menu comes up but I cannot click on any of the buttons. Its just frozen, the JOptionPane pops up telling me I am not connected to mySQL but thats about it. I am using MVC type of a design. Code will be below.
package addItemBtn.Home.DataBase; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.TextEvent; import java.awt.event.TextListener; import javax.swing.event.DocumentListener; public class AddItemController { private AddItemModel model; private AddItemView view; AddItemController(AddItemModel model,AddItemView view) { this.model = model; this.view = view; //adding actionListeners for the AddItemClass view.cancelBtn.addActionListener(new ActionListeners()); view.submitBtn.addActionListener(new ActionListeners()); view.previewBtn.addActionListener(new ActionListeners()); view.nameBox.addActionListener(new ActionListeners()); view.priceBox.addActionListener(new ActionListeners()); view.locationBox.addActionListener(new ActionListeners()); view.descriptionBox.getDocument().addDocumentListener((DocumentListener) new ActionListeners()); view.frame.setVisible(true); } class ActionListeners implements ActionListener, TextListener { @Override public void actionPerformed(ActionEvent e) { try { if(e.getSource() == view.submitBtn) { System.out.println("submit Pressed"); model.setName(view.getName()); model.setLocation(view.getAddress()); model.setPrice(view.getPrice()); model.setDiscription(view.getTextArea()); } else if(e.getSource() == view.cancelBtn) { view.frame.dispose(); System.out.println("Cancel Pressed"); } else if(e.getSource() == view.previewBtn) { System.out.println("Preview pressed"); model.setName(view.getName()); model.setLocation(view.getAddress()); model.setPrice(view.getPrice()); model.setDiscription(view.getTextArea()); } else { System.out.println("else"); } }catch(Exception ex) { System.out.println("There was an error "+e); } } @Override public void textValueChanged(TextEvent e) { String text; try { if(e.getSource() == view.descriptionBox) { text = view.descriptionBox.getText(); System.out.println(text); } }catch(Exception ex) { System.out.println("There was an error text area "+ex); } } } }
package addItemBtn.Home.DataBase; import mainMenu.Home.DataBase.StartUpMenu; import mainMenu.Home.DataBase.StartUpMenuController; public class AddMain { public static void main(String args[]) { StartUpMenu menu = new StartUpMenu(); AddItemView view = new AddItemView(); AddItemModel model = new AddItemModel(); new StartUpMenuController(menu); new AddItemController(model,view); } }