aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Who should save window settings in Swing MVC? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Who should save window settings in Swing MVC?" Watch "Who should save window settings in Swing MVC?" New topic
Author

Who should save window settings in Swing MVC?

Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Hi,

I'm writing an application (for my OCMJD) using Swing and MVC (using three distinct classes). I want to load and save the window state such as location and size when the application starts and stops. The settings are very specific to Swing and therefore wouldn't be suitable to keep it in the model so should this code be in the Controller or the View? My gut feeling is to put it in the View but I'm looking for some advice from the more experienced coders out there.

Thanks

Chris.


SCJA, OCPJP, OCMJD
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1665
    
    7

I've used the ViewHandler pattern in combination with the Model-View-Controller.
I read about it in Pattern Oriƫnted Software Architecture vol. 1, but I'm sure you could find a description of it online somewhere.
It's usually applied in the context of an mulit-view / multi document interface, and the ViewHandler is responsible for opening and keeping track of views, updating them and disposing of them when necessary. I guess it could also be made responsible for persisting a view's state as it gets disposed.

Edit: the links to the ViewHandler class are added automatically, I didn't inted for that to happen.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Thanks. That makes more sense than using the view itself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Who should save window settings in Swing MVC?
 
Similar Threads
MVC and Java Swing
MVC in Java Text Component
Information on Controller
Applying pure MVC to Swing/JFC
how to use MVC architecture in Java Swing application