How to solve a problem related with implementing Inheritance?

Hello,
So i come on this way to ask for help about implementing Inheritance on my application. So the problem is:
I am making a Application which i need to capture audio and that analyze that capture by Spectrum Analyzer, Volumes etc.
And I will use several microphones in this application so i will use same code in capturing audio.
I have a class called Application which has the GUI and the events, like button events and update the values in the GUI. In my first version of the Application i had everything here but i don´t like that and is not good for the performance so i want to divide the code by other classes. Thats why i am trying the Inheritance.
So i created a class called Equipment which is the superclass and in this class will have the method captureAudio(), calculateRMSLevel(), sendOutPresenceUpdates() etc.. And i have 3 variables:
public abstract class Equipment {
    public AudioFormat format;
    public TargetDataLine line;
    public Mixer mixer;
    public EventListenerList listenerList = new EventListenerList();
    public Equipment(AudioFormat format, TargetDataLine line, Mixer mixer){
        this.format = format;
        this.line = line;
        this.mixer = mixer;
    public AudioFormat getFormat() {
        return format;
    public void setFormat(AudioFormat format) {
        this.format = format;
    public TargetDataLine getLine() {
        return line;
    public void setLine(TargetDataLine line) {
        this.line = line;
    public Mixer getMixer() {
        return mixer;
    public void setMixer(Mixer mixer) {
        this.mixer = mixer;
     public int calculateRMSLevel(byte[] audioData){
     // audioData might be buffered data read from a data line
        long lSum = 0;
        for(int i=0; i<audioData.length; i++)
            lSum = lSum + audioData;
double dAvg = lSum / audioData.length;
double sumMeanSquare = 0d;
for(int j=0; j<audioData.length; j++)
sumMeanSquare = sumMeanSquare + Math.pow(audioData[j] - dAvg, 2d);
double averageMeanSquare = sumMeanSquare / audioData.length;
return (int)(Math.pow(averageMeanSquare,0.5d) + 0.5);
public void sendOutPresenceUpdates(int FullJIDAndResource, String NewPresence) {
     Object[] listeners = listenerList.getListenerList();
     Integer inputValue = _FullJIDAndResource;
     String convertedValue = inputValue.toString();
// Empty out the listener list
     // Each listener occupies two elements - the first is the listener class and the second is the listener instance
for (int i=0; i < listeners.length; i+=2) {
          if (listeners[i]==CustomPresenceListener.class) {
               ((CustomPresenceListener)listeners[i+1]).presenceEventOccurred(new CustomPresenceEvent(this, convertedValue, _NewPresence));
public void listenForPresenceEvents(CustomPresenceListener _listener) {
          listenerList.add(CustomPresenceListener.class, _listener);
public void removeEventListener(CustomPresenceListener _listener) {
          listenerList.remove(CustomPresenceListener.class, _listener);
public void captureAudio(){
And i have questions about the constructor, is right the constructor that i created in the superclass?
So i create a subclass called Microphone1 and in this class i make override from the method captureAudio() from the superclass and here i create the thread for the capture.class Microphone1 extends Equipment{
public Microphone1(AudioFormat format, TargetDataLine line, Mixer mixer){
super(format,line,mixer);
public void captureAudio(){
try{
format = getFormat();
Mixer.Info[] mixerInfo =AudioSystem.getMixerInfo();
//DataLine.info get the information about the line.
DataLine.Info info = new DataLine.Info(TargetDataLine.class,format);
Mixer mixer = AudioSystem.getMixer(mixerInfo[3]);
// get the info from the desired line.
line = (TargetDataLine)AudioSystem.getLine(info);
//Get a TargetDataLine on the selected mixer.
line = (TargetDataLine) mixer.getLine(info);
line.open(format);
line.start();
CaptureThread captureThread = new CaptureThread();
captureThread.start();
} catch (Exception e) {
System.out.println(e);
System.exit(0);
}//end catch
But now i have a problem in the class Application, because i want to start the capture when i click in the button so i created the actionPerfomed and inside of this event i create this:Microphone1 m1 = new Microphone1(format,line,mixer);
m1.captureAudio();
But when i execute the application and click in the button appears this: java.lang.NullPointerException :/ and i don't know how to solve this.
Any help? Where i am wrong?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Hello Kayaman,
Well thinking in that way is not good creating the Microphone1 object every time i click in the button.
So i put e.printStackTrace in the catch block the show me this error:
java.lang.NullPointerException
at com.sun.media.sound.Toolkit.isFullySpecifiedAudioFormat(Toolkit.java:137)
at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:98)
at com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:139)
at App.Microphone1.captureAudio(Microphone1.java:42)
at App.Application.startBtnActionPerformed(Application.java:529)
at App.Application.access$000(Application.java:29)
at App.Application$1.actionPerformed(Application.java:152)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6267)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6032)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
at App.Microphone1.captureAudio(Microphone1.java:42):
This error is about this line: line.open(format);at App.Application.startBtnActionPerformed(Application.java:529): m1.captureAudio();:/

Similar Messages

  • How to solve the problem related with inputing of the text into Wordpress from Firefox 9 and 9.0.1. The problem is that after inputing the formatting gets lost. Taking in account high popularity of Wordpress I suppose the problem is quite serious.

    How to solve the problem related with inputing of the text into Wordpress from Firefox 9 and 9.0.1.
    The problem is that after inputing the formatting gets lost.
    Taking in account high popularity of Wordpress I suppose the problem is quite serious.

    Perform the suggestions mentioned in the following articles:
    * [https://support.mozilla.com/en-US/kb/Template:clearCookiesCache/ Clear Cookies & Cache]
    * [[Troubleshooting extensions and themes]]
    * Clipboard not working -> [http://kb.mozillazine.org/Clipboard_not_working]
    * Rich Text Editing -> [http://kb.mozillazine.org/Rich_text_editing]
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    Check and tell if its working.
    Might not be related to your problem but some of your Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • How can i solve the problem relate with gmail links opening in firefox ? New link start in new tab and disconnects.Also youtube streaming breaks everytime .

    Firefox disconnects by clicking link in my gmail and most of time i refreshes the page few clicks. And also some problem relate with playing youtube videos. I frankly notice that i connect my net using PC Suite and also system protected with Anti virus program. So kindly check my browser and restore it's missing without using factory reset. Notify me for any urgent update of yours 16th version. Thanking for yours brilliant support .
    Jaison James.

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • Hi, when ever I'm using 3G, on my Iphone4 sim stops working and Network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem.

    Hi, when ever I'm using 3G, on my Iphone4 sim stops working and network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem. Thanks.

    Photos/videos in the Camera Roll are not synced. Photos/videos in the Camera Roll are not touched with the iTunes sync process. Photos/videos in the Camera Roll can be imported by your computer which is not handled by iTunes. Most importing software includes an option to delete the photos/videos from the Camera Roll after the import process is complete. If is my understanding that some Windows import software supports importing photos from the Camera Roll, but not videos. Regardless, the import software should not delete the photos/videos from the Camera Roll unless you set the app to do so.
    Photos/videos in the Camera Roll are included with your iPhone's backup. If you synced your iPhone with iTunes before the videos on the Camera Roll went missing and you haven't synced your iPhone with iTunes since they went missing, you can try restoring the iPhone with iTunes from the iPhone's backup. Don't sync the iPhone with iTunes again and decline the prompt to update the iPhone's backup after selecting Restore.

  • I have a problem in my iphone 4 with wi-fi after update to IOS6 please can help my how can solve this problem?

    I have a problem in my iphone 4 with wi-fi after update to IOS6 please can help my how can solve this problem?

    Nope
    One needs to press the home and sleep / wake keys together for the phone to reset
    The other thing I could recommend
    Let the battery run out and the phone completely "die"
    It may take a day or two with it not being used
    Then plug it in to charge and see if there is any change in behavior
    If you cannot get this to work - you may need to bring it to an Apple store

  • Downloading and installing the iOS5.0.1 Following problems occured: with my iPhone 4s: Phone calls are dropping out in UAE, how to solve the problem?

    Downloading and installing the iOS5.0.1 Following problems occured: with my iPhone 4s: Phone calls are dropping out in UAE, how to solve the problem?

    You're not speaking to Apple on in this forum, nor will someone from Apple see this post.   We are just users like you and I.
    Have you tried to restore or reset your phone?
    Or contact your carrier in re: to your sim card

  • Graphics card Quadro K4200 don't work with cuda in Adobe Premiere CS 6 version 6.0.5. Maybe they are bad drivers for graphics card? How to solve this problem?

    I have purchased graphics card Quadro K4200, but graphics card don't work with cuda in Adobe Premiere CS 6 version 6.0.5. Maybe they are bad drivers for graphics card? How to solve this problem?

    Did you use the nVidia Hack http://forums.adobe.com/thread/629557

  • My FaceTime is active but it does not connect. Any one know what is wrong with it or how to solve the problem?

    My FaceTime is active but it does not connect. Any one know what is wrong with it or how to solve the problem?

    Please sign out of FaceTime and sign back in. If there's no change, log out or restart the computer and try again.

  • Since I use Mac os x mountain lion it is no more possible to share files with my pc windows 7. Does somebody know how to solve this problem?

    Since I use Mac os x mountain lion it is no more possible to share files with my pc windows 7. Does somebody know how to solve this problem? I have been answered by an Apple technician that with the new Mountain Lion the problem was with Windows. I am not convinced.

    I have renamed my pc and everything is ok with the file sharing SMB. Both my iMac and my pc can share files very easily.

  • How to solve this problem on screenfetch?

    Hi guys!
    Can you please tell me how to solve this problem on screenfetch? When I start the program, it shows me this message below:
    No value set for `/desktop/gnome/interface/gtk_theme'
    No value set for `/desktop/gnome/interface/icon_theme'
    No value set for `/desktop/gnome/interface/font_name'
    I'm currently using XFCE 4.8 and this is some more information:
    $ uname -a
    Linux archbox 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011 i686 Intel(R) Core(TM)2 Duo CPU T5450 @ 1.66GHz GenuineIntel GNU/Linux
    Picture related:
    Last edited by coruja (2011-10-03 14:14:42)

    I think you just miss gtkrc.. Try to create or generate one with for example gtk-theme-switch2.

  • I recieve SMS and i hear established melody and I do't hear the person on all over SMS. How to solve this problem?

    Problem with an incoming message. For example, during my conversation the second line receives a call, I hear the sound in dynamics such as "piiiip piiiip," but when in this situation I recieve SMS and i hear established melody and I do't hear the person on all over SMS. How to solve this problem? Perhaps someone tell me? save in advance

    Not Charge
    - See:     
    iPod touch: Hardware troubleshooting
    iPhone and iPod touch: Charging the battery
    - Try another cable. The cable for 5G iPod (lightning connector) seems to be more prone to failure than the older cable.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar

  • I Try to open an Indesign document. The message: it is made in a newer version. Go tot CC: Help/Give your Adobe id/Start Indesign again and try to open the document. This doesn't work. How to solve this problem?

    I Try to open an Indesign document. The message: it is made in a newer version. Go tot CC: Help/Give your Adobe id/Start Indesign again and try to open the document. This doesn’t work. How to solve this problem?

    What version are you running?
    What version was it made with?

  • I'm using windows 8 on my pc, and i have just downloaded the latest version of itunes, after i upgraded the latest version of itunes, it can't detect my iphone, but my windows/my pc does. Anyone knows how to solve this problem?

    I'm using windows 8 on my pc, and i have just downloaded the latest version of itunes, after i upgraded the latest version of itunes, it can't detect my iphone, but my windows/my pc does. Anyone knows how to solve this problem?

    Hi jstutsman,
    If you are having issues with your iPod nano not being recognized in iTunes after a recent update, you may find the steps and links listed in the following article helpful:
    iPod not appearing in iTunes - Apple Support
    Regards,
    - Brenden

  • Why i can not open my itunes how to solve this problem

    i have problem with my itunes version 10.3 but it said the file itunes library it could'nt be read it was created by new version of itunes where i can go to find the library of itunes or how to solve this problem..

    Hello:
    This article may help:
    http://docs.info.apple.com/article.html?path=Mac/10.7/en/mh11399.html
    Are you really running OS X 10.4 or is your profile out of date?
    Barry

  • My iPad Mini iOS7 is showing only Apple Logo which happened during software update. I tried to restore using iTunes but it asking me to response from iPad. But my ipad only shows apple logo. How can i response? How to solve this problem?

    My iPad Mini iOS7 is showing only Apple Logo which happened during software update. I tried to restore using iTunes but it asking me to response from iPad. But my ipad only shows apple logo. How can i response? How to solve this problem?

    FORCE IPAD INTO RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTunes (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port.
    DO NOT RELEASE BUTTON until you see picture of iTunes and plug
    5. Release Home button.
    ON COMPUTER
    6. iTunes has detected iPad in recovery mode. You must restore this iPad before it can be used with iTunes.
    7. Select "Restore iPad"...
    Note:
    1. Data will be lost if you do not have backup
    2. You must follow step 1 to step 4 VERY CLOSELY.
    3. Repeat the process if necessary.

Maybe you are looking for

  • How to  not update the model value whe, multiple back-end validation failed

    Hello ! I have a save button who perform in backend code multiple validations on some fields. The validations can be ok, if not, I show specific error messages in my page. It's working fine. The problem is that all the InputText I need to valid are v

  • FF will not start for ONE Windows 7 User. All others work fine.

    I try to start FF and it hangs. Loads into Project Manager, but no browser window.

  • Tags that end but dont

    In my custom tag library, I have an HTML tag that will write out HTML along with any attributes it is passed: <tl:HTML name="img">   <tl:HTMLattribute name="src" value="myImg.gif"/> </tl:HTML>I do that by extending BodyTagSupport and not writing the

  • Bootstrap3/BC Menu dropdown conflict with module_photogallery

    I'm building a site using Bootstrap3 framework, with BC Dynamic Menu (with jQuery courtesy Joe Watkins) for main navigation.  Dropdowns (click or hover) working beautifully until I add a photogallery module, then the dropdown links disappear on click

  • Redo logs status - Invalid

    I have added new members to my redo log groups. However, when checking the redo log members' status, all the new members have a status of "Invalid" even after restarting the database. I have checked that the physical files of the new members are crea