Note that there are some explanatory texts on larger screens.

plurals
  1. POModel View Presenter and Composite Views
    primarykey
    data
    text
    <p>I'm trying to follow the MVP (specifically Passive-View) pattern in a java swing ui application.</p> <p>The basic design of the application reminds a wizard control. The screen is divided to two main parts:</p> <ul> <li>an active view.</li> <li>a static navigation bar, with navigation buttons. </li> </ul> <p>The user can use buttons to change the active view, but the bar is always displayed. </p> <p>Modeling this scenario, I have a bunch of diffirent screers, each with it's own presenter, view interface and view implementation (using JPanel). Then I have a Shell presenter, view intefrace and view implementation, using a JFrame. The idea is that the shell will load first and always by displayed, showing the bottom navigation bar and leaving a space for the active view. The shell presenter will allow setting the current active screen, somewhat like this:</p> <pre><code>interface View { } class Presenter { View view; public Presenter(View view) { this.view = view; } public View getView() { return view; } } interface ShellView extends View { void setActiveView(View activeView); } class ShellPresenter extends Presenter { private ShellView shellView; public void setActivePresenter(Presenter activePresenter) { shellView.setActiveView(activePresenter.getView()); } } class ShellFrame implements ShellView { private JFrame frame; private JPanel activePanel; private JPanel navigationBar; public ShellFrame() { Container c = frame.getContentPane(); c.add(activePanel); c.add(navigationBar); } public setActiveView(View activeView) { ??? } } </code></pre> <p>The problem is in the setActiveView method: I'm not sure how to set the activeView to the activePanel, when the View interface is general and as such doens't know anything about JPanels. Obviously I wouldn't want my presenters to know about JPanels as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload