This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I trying to implement a program that is based on MVC model. Is my first time and I'll like some help. I have few classes that contains JButtons, JLabels, etc. those are my View. Also, I have a class that implements ActionListener and MouseListener and my View classes extends this Controller class. So, my obstacle is how I will connect each button or label in every class to this Controller class, so when button pressed to do something? Need a small sample code please.
Thank you so much about the code, helps a lot. Need to have for each button I have in my program, or is multi-usable with this way? Also, if I have an empty JTextField in the ViewImpl and a button, and want when button pressed the JTextField filled with "Hello", how I will do this using MVC?
** Didn't notice this before, sorry
What is contained in those classes View and Model where you implement these classes?
Joined: Mar 12, 2011
Pan Niko wrote:What is contained in those classes View and Model where you implement these classes?
They are interfaces. They might look something like this:
Finally, decided to have one controller per each view class I have, and also, implements my view classes to Observer and my model class to Observable. By using interfaces with the way I'm working, is still helpful?