MVC : How to pass object from model back to View
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi all,
I'm new to Swing, now i work on the project that use MVC pattern. I try to seperate my application into 3 packet, model view controleur (ActionListener). I write one small application, in view, i create texte field and one button. When user click on button the controleur pass the texte to the model. I just try to change some content of the texte and I want to write that texte on the view, but i dont know how to pass that text to view. Any idear on this, i really appriciate your help.
Moniphal
[ January 25, 2005: Message edited by: Moniphal SAY ]
I'm new to Swing, now i work on the project that use MVC pattern. I try to seperate my application into 3 packet, model view controleur (ActionListener). I write one small application, in view, i create texte field and one button. When user click on button the controleur pass the texte to the model. I just try to change some content of the texte and I want to write that texte on the view, but i dont know how to pass that text to view. Any idear on this, i really appriciate your help.
Moniphal
[ January 25, 2005: Message edited by: Moniphal SAY ]
<b>The more we learn, the more we know !</b>
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
JTextField.setText("update string");
ms<br />SCJP, SCJD
Moniphal Say
Ranch Hand
Posts: 48
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi ,
Mike, thanks for your reply. My problem is that in my class View, I cant not get the texte from class Model. I dont know how to pass the texte to the view.
I have classe View.java, in that I add JTextField and JButton which I set the actionCommand and addActionLister to the button.
I have classe MyActionListener.java extends ActionListener, in which I can get the texte from the JTextField in View.java and store in variable "texte". And I call one method of class Model.java that I passed variable "texte" as argument.
In the method of class Model, I change the contente of the variable texte and I want to write that texte in View or call the method repaint() of View or make the view call repaint() automatically. Is there any way to do that or it cant be do that?
Regards,
Moniphal
Mike, thanks for your reply. My problem is that in my class View, I cant not get the texte from class Model. I dont know how to pass the texte to the view.
I have classe View.java, in that I add JTextField and JButton which I set the actionCommand and addActionLister to the button.
I have classe MyActionListener.java extends ActionListener, in which I can get the texte from the JTextField in View.java and store in variable "texte". And I call one method of class Model.java that I passed variable "texte" as argument.
In the method of class Model, I change the contente of the variable texte and I want to write that texte in View or call the method repaint() of View or make the view call repaint() automatically. Is there any way to do that or it cant be do that?
Regards,
Moniphal
<b>The more we learn, the more we know !</b>
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
To the best of my knowledge in an MVC pattern the View and the Model have a reference to each other. The View would implement some listener interface of the Model, and the View would hold onto a reference of the Model, usually an Interface type.
| knowledge is the difference between drudgery and strategic action -- tiny ad Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |









