Re: Design issue in swing application
Fencer wrote:
On 2010-02-17 17:41, Lew wrote:
Fencer wrote:
MVC, hmm. Ok, so imagine WelcomePanel is a view and instead of knowing
about the CenteredGroup class directly it knows about an interface for
a Controller.
Normally you'd do it the other way around - the controller knows about
the view, but the view doesn't know about the controller.
When the user presses the button "Open BioModel" the view informs the
controller about this. What should happen now is that a file
This is where the controller knows the view. The central view method
returns a value, and takes arguments, that the controller understands.
The view types know nothing about how the arguments are created or the
return values are used.
Thanks for your reply.
I will read some more and try to make a concept implementation. Just one
question, if the view (a JPanel in my case) doesn't know about the
controller but the controller knows about the view, how should I
implement my button listener? Right now it's an anonymous inner class to
the JPanel-extended class, I don't get how to handle that and not have
the view know the controller?
The listener does exist in the view because it's part of the view. If you
actually read the links to which I pointed, you will see that ultimately the
job of the view is to return state to the controller; you can do that from the
listener or from some other part of the view triggered by the listener.
Read the links, explore their transitive links, think about what you've read,
play with it for a while, then ask questions, in that order. If you haven't
even assimilated the information already provided, then you're going to ask
redundant questions. Read, study, experiment, then ask.
--
Lew