• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Application Event Framwork

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm currently developing a large application and have therefore separated functionality into a number of classes which extend JPanel and handle all events locally. These classes are created in the MainClass along with a JMenuBar and JToolBar.
I have also created a number of Action classes which extend AbstractAction which are used by the MenuBar and Toolbar, such as CopyAction, CutAction, etc.
I need a framework for informing objects, contained within the JPanels and child JPanels that a cut/copy event has occurred. I've read about the HMVC (Hierarchical Model View Controller) paradigm but I think it's a bit heavy-weight for what I'm trying to achieve.
Anyone got any ideas?
Thanks
Jason.
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done something like this. I set up a listener interface for my objects that have to be aware of changes made somewhere else. Then in the aware object(the one that causes/knows about the changes) I kept an array/vector of the objects that were registered as listeners then had to run through a for loop and hit each one whenever there was a change. It makes it slightly inconvenient because all your objects that are listeners have to be custom(although just barely) so that they know what to do when you tell them you copied or pasted something. You could set everything up to listen to the same reports no matter what kind of report it was, or you could go so far as to break each different type of action into it's own set of listeners.
Its a pain to setup sometimes, but it really makes updating stuff and triggering special events alot easier. If you need more details, I can give you some examples of what I did.
HTH
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic