I am learning out design patterns and doing a little fun project on Model Control View (MCV). I got the concept down, it is pretty simple for the most part. However my buttons are not working. Here is the code:
public class Controller { private Model model; private View view; Controller(Model model, View view) { this.model = model; this.view = view; } class addListeners implements ActionListener { String name, age, address; @Override public void actionPerformed(ActionEvent e) { try{ if(e.equals(view.btnEnter)) { name=view.getName(); age=view.getAge(); address=view.getAddress(); model.printResult(name, age, address); } else if(e.equals(view.btnClose)) { view.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } else { System.out.print("There was an error!"); } } catch(Exception ex) { System.out.println(ex); System.out.println("There was an error!"); } } } }
Main Method
It runs but nothing. My other questions is how can I make a box that will print the results. What option in swing offers that. I naturally already googled this but I keep getting JOptionDialog, pretty sure that is not what i want.