I implemented the MVC pattern for Java SE with Swing using PropertyChageSupport and PropertyChageListener . The diagram for the implemented MVC is as follows.

In the implementation of View I change the property in Model using Controller .
View contains the following code for the Ok button.
btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { modelController.setNumber(Integer.parseInt(numberField .getText())); modelController.setName(nameField.getText()); } });
Full code can be found in SwingMVC .
Now, my question is: I am writing the above code for btnOk in View or should I write it in the Controller method so that in View , I'll 'do
btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { modelController.btnOkActionPerformed(); } });
From the above two implementations, which is the preferred way to implement MVC?
TheKojuEffect
source share