Campbell Ritchie wrote:Well done, but please tell us how ou sorted it, so everybody here can learn.
Nothing special really.
Having 3 classes that needs to be updated depending on event: ToolBar, Thumbnail, SingleView
Plus having class, MainPanel, that group above GUI components.
I known that I will need to create some "data" class to "house" some operations, store and share file path once selected, plus provide facilities for adding/removing/notifying listeners. On other hand there was need for some interfaces to dictate some classes.
At the start I created StatusListener interface with methods fileToOpen(), fileToSave(), fileToClose(). This interface is implemented in that 3 classes(ToolBar, Thumbnail, SingleView) so once event occur they will be notified and do they business depending on each class.Then I created StatusEvent interface with add/remove/notify for each of StatusListener interface methods. The interface is implemented in "data" class called Manager. Manager class provide behind scene operations that are triggered by toolbar, but not strictly related only to toolbar (sort of general management for all 3 main components). On top of that it does work as safe-keeper of file path or current "working" file.Each of the 3 classes has a need to register its listeners with Manager class(here is where I made mistake in first place, a dumb mistake of providing each class with own instance of Manager). MainPanel as direct grouping component is well suited for creating new instance of Manager class and passing references to ToolBar, Thumbnail, SingleView as it is adding them in layout.