I need to create an application with single window and without any popups. Everything works using same window and only changing content. I am going to create application using swing.
I have read Java: single frame vs multiple frames but I don't think that would suite my requirements because when application will grow it get's more difficult to maintain.
I would like to have MVC design. I am thinking about creating some sort of stack of controllers where controller will load view and model. So when I'll need to go back simply pop current controller and use previous one. I can be wrong about my design, if anyone have any suggestions how to implement such application feel free to comment.
Thank's for your time.
I have tried creating prototype class which would hold stack of containers to switch between.
public class WindowManager
{
protected Stack<Container> frames;// contains frames stack to navigate
protected JFrame wnd; // frame to show
public WindowManager()
{
this.frames = new Stack<>();
this.wnd = new JFrame();
wnd.setSize(640, 480);
//wnd.setVisible(true);
}
public void addFrame(Container c)
{
this.frames.push(this.wnd.getContentPane());
this.wnd.setContentPane(c);
}
public WindowManager removeFrame()
{
Container c = this.frames.pop();
wnd.setContentPane(c);
return this;
}
public void showWindow()
{
wnd.setVisible(true);
}
}
Instead of containers stack there would be Controllers stack which would load view and model.