I have a panel called DataPanel which extends JPanel, and a worker called DataPanelWorker which extends SwingWorker.
Currently when I create the DataPanel, I start the DataPanelWorker which does some calculations and fires property changes after each calculation.
The DataPanel listens for these property changes and displays a message each time. e.g. "Calculation 1 complete" "Calculation 2 complete"
This works fine!
What I now want to do now is create a second instance of DataPanel (let's call this DataPanel2) but I want to use the original DataPanelWorker to save computation. I register DataPanel2 as another propertyChangeListener on DataPanelWorker.
My problem is I might register DataPanel2 after calculation 1 has been completed and the first propertyChangeEvent has been fired. How can I know how far through the worker is so that I can get DataPanel2 to be displaying the same messages as DataPanel1?
What I would like ideally is to keep a queue of propertyChangeEvents and when registering a new component, fire them all on just that component. Is there a standard way of doing this? Or am I looking at it from the wrong view?
Thanks