I want to write an application in Java SWING using the MVC architecture, but I have problem with using multiple controllers because I don't know how to do this.
public class Application {
public static void main(String[] args) {
Application app = new Application();
app.Start();
}
public void Start()
{
MainModel model = new MainModel();
MainView view = new MainView();
MainController controller = new MainController(view,model);
view.setVisible(true);
}}
MainController:
public class MainController {
private MainView theView;
private MainModel theModel;
public MainController(MainView theView, MainModel theModel)
{
this.theModel = theModel;
this.theView = theView;
}}
MainView:
public class MainView extends JFrame{
private JMenu menu = new JMenu();
public MainView()
{
JPanel panel = new JPanel();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(800,800);
panel.add(menu);
this.add(panel);
}}
I do not put here because the model is now empty.
Okay, so I don't know how to use multiple controllers. For example: I want to create new controller UserController and I don't know how to implement this. Should I create new controller in MainController? If I create UserController in MainController how to use it?