Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to implement Observer Pattern?

847432Mar 31 2011 — edited Apr 4 2011
Hello 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
This post has been answered by TPD-Opitz on Apr 4 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 2 2011
Added on Mar 31 2011
82 comments
1,178 views