In MVC the model is the code that carries out some task.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
instance of the Document interface
For a checkbox component, the data model could be a single Boolean variable, indicating whether it's checked or not. The behavior for handling mouse-click events would alter the model, and the view would examine that data when it draws the on-screen representation.
Probably not. No. The text shown is only used by the user, not usually by the rest of the code, so I wouldn't call it the model myself. I am sure people will disagree, however.abalfazl hossein wrote:Then, I think that for JButton the string that is shown on Button is the model.Right?
The Model is where the data for the component is stored. For example, in a JButton the button label is part of the button's model. In a JList, the list data is in the List Model. Ok.
An Example...
An example/analogy might help here, so let's use a JList and a computer. The JList has a model - in fact, it's called a ListModel. The ListModel is pretty much a Vector of the different strings you want to display in the JList. In the computer analogy, the model is the hard drive.
State Model for buttons. This model is used for check boxes and radio buttons, which are special kinds of buttons, as well as for normal buttons. For check boxes and radio buttons, pressing the mouse selects the button. For normal buttons, pressing the mouse "arms" the button. Releasing the mouse over the button then initiates a button press, firing its action event. Releasing the mouse elsewhere disarms the button.
For a checkbox component, the data model could be a single Boolean variable, indicating whether it's checked or not. The behavior for handling mouse-click events would alter the model, and the view would examine that data when it draws the on-screen representation.
abalfazl hossein wrote:ButtonModel is just an interface, That is it.and an interface can not store data.Then How can it be a model?A model stores a data according to the tutorial, Like database like file like variable.
Dear Stephan, Are agree with that post that I told only a variable can be model?
** Is business logic equal to controller?
Models are not data access objects;
Probablyabalfazl hossein wrote: . . . Models are not data access objects
Agree?
Probably, but not certain.Are methods that manipulate data part of model?
No, because what you posted didn't have enough details to be sure. Also the boundaries between M and V and C may be indistinct.abalfazl hossein wrote:probably? May you tell more details?
Don't get me started about those stupid light bulbs. |