Stefano Maglione
Stefano Maglione

Reputation: 4150

Share model object in java mvc

I'm making an application by MVC architecture. My question is: how can I share an istance of a model between many classes in controller?

It is difficult 'cause I'm using a listener,I would call by this listener a controller passing it a model:

class ButtonListener1 implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {

        System.out.println(e.getActionCommand());


        if(e.getActionCommand().equals("Inizia")){

            //call a controller passing it a model
        } 

    }


}

Upvotes: 0

Views: 52

Answers (1)

Mad Physicist
Mad Physicist

Reputation: 114230

When you construct a button, you can set the model.

Upvotes: 1

Related Questions