Controller logic

Report a typo

Which of the following represents the controller logic for a Swing application based on MVC?

class Controller {
    private Model model;
    private View view;
    private ActionListener actionListener;

    public Controller(Model model, View view) {
        this.model = model;
        this.view = view;
    }

    public void control() {
        actionListener = actionEvent -> {
            model.increment();
            view.setText(Integer.toString(model.getNumber()));
        };
        view.getButton().addActionListener(actionListener);
    }
}
Select one option from the list
___

Create a free account to access the full topic