• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Who should save window settings in Swing MVC?

 
Chris Zaremba
Ranch Hand
Posts: 54
Eclipse IDE Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chris Zaremba
Ranch Hand
Posts: 54
Eclipse IDE Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. That makes more sense than using the view itself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic