jQuery in Action, 3rd edition
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "MVC" Watch "MVC" New topic


Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 80

Hi everybody!

I like to get one or more opinion about my MVC [VC] to be exact! When i read and learn some thing about MVC i have a lot of theoretical examples, but no much practical examples... My doubt is simple: is this correct? (see pseudo-code)

MyController c = new MyController();

MyView v = new MyView(c);

//Inner MyView class exists a constructor:

MyView(MyController c){

Is this Correct? Or there is a best way to associate controller/controlled classes?


Julio Cesar Lopes Marques
Sun Certified Java Developer 5, Sun Certified Java Programmer 5
Roberto Perillo

Joined: Dec 28, 2007
Posts: 2271

Fala Julio!

Since we are talking about Swing, you can face ActionListeners as controllers, and JFrames as views. This is how I did the main window of my project:

So you can have an instance of the view in the controller.

Here is a very interesting article about GUI architectures, which also talks about the MVP pattern (a kind of MVC). I think it might be helpful!

Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 80

Thanks again Bob!
Roel De Nijs

Joined: Jul 19, 2004
Posts: 8359

Is there any difference between doing it like Roberto showed and using a seperate (anonymous) (inner-)class? And i mean difference in good or bad, from a design perspective ? I know there is a difference in code

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
I agree. Here's the link: http://aspose.com/file-tools
subject: MVC
It's not a secret anymore!