What’s the most efficient method of implementing a shared data object between multiple JInternalFrames on a single JDesktopPane?
Not sure whether to go with singleton or can I put a data object in the JDesktopPane and access from a component? I don’t want to keep separate instances of this data for each frame (lots of frames)
I would steer clear of singleton (as it’s a-kin to using global variables – See here for a description) and instead subclass
JInternalFrameto contain a reference to the shared data object; e.g.Obviously despite having multiple references to your SharedData (one per MyInternalFrame instance) there is still only one
SharedDataobject in your system; i.e. you are not duplicating data with this approach.