How to implement Observer Pattern?
847432Mar 31 2011 — edited Apr 4 2011Hello guys,
I have some problems with implementing the observer pattern. So i m making an sound application and i need to put a meter changing with the volume.
I have already the meter designed and the volume is calculated.
So i have a class called Application (is the main class) and this class have the graphic designer from the application, makes the audio capture and calculate the volume.
And i have the MeterMic class and in this class i have the graphic Meter where i send this graphic meter to the application via JPanel.
In MeterMic i have the variable "value" and this variable will make the changes in the bars of the meter and i want to equal the value to the volume from the application. I try referencing by the Application object but doesnt pass the value from the volume.
So i would like to implement the Observer pattern.
I need to observ the variable volume and than the volume have changes i want to send that change to variable value in MeterMic.
My problem is: who is the observer and observ? And what i need to do to implement the pattern.
My best,
David