Search code examples
javaswingjframeobserver-pattern

Multiple similar GUI windows java


I am working with JFrame and observers. I have a functioning GUI with multiple buttons and functions.

I am trying to create a button which opens a new window, that is exactly the same as the main window. All changes in any window, should be automatically updated to all open windows.

Any help how to begin?


Solution

  • General suggestions:

    1. Use Model-View-Control or MVC design pattern,
    2. use a factory method to create your sub-views (or as you call them, windows), createWindow(Model model), and
    3. give each sub-view the same shared model object.