Hi Guys,
I am quite experienced in programming with Java. I have though come accross a small problem, I don't know how to implement the MVC pattern. I understand the concepts of the MVC pattern and I was hoping that someone on this forum could help.

I have a model which is just a class that adds 2 integers together and returns the answer. The code is shown below.

public class Adder
{


public int add(int x, int y)
{
return x + y;
}
}

Now what I want to do is apply the MVC pattern to the above model. I want to have a Swing interface with 2 textboxes and an equals button which then displays the answer. How do I apply the MVC pattern?

Please don't try and mix the view and contoller in one - keep it separate.

Thanks

And is there a particular reason you need a separate controller and don't want the view to serve that role? If you don't have the answer then you probably don't need to. Keep the model separate and let the view interact with it as needed.

I want a separate controller because I just want to see how its done. I'm guessing that in larger applications you need a separate controller & view? If you could just show me a sample I would be grateful. Thanks.

i still dont understand.

in that case you should go back to tha basics and try some more things on the level of "Hello World".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.