• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in using Inner classes

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am having problems using inner classes in Java.

I was trying out a code given in "Head First Java" 2nd Ed. Page392.


I have an inner class that implements ControllerEventListener interface.

<Code> :

class MydrawPanel extends JPanel implements ControllerEventListener

{

//Code for the inner class

}


In the outer class I have instances of MyDrawPanel and Sequence.

<Code>

static MyDrawPanel m1 = new MyDrawPanel();
Sequencer sequencer = MidiSystem.getSequencer();

I get an error when I use this line:

sequencer.addControllerEventListener(m1,new int[] {127});

The Compilation error I get is
<error>
addControllerEventListener(javax.sound.midi.ControllerEventListener, int[]) in javax.sound.midi.Sequencer cannot be applied to (MyDrawPanel,int[]) .

I cannot understand why I am getting this error though MyDrawPanel implements ControllerEventListener.

Please let me know.

Thanks in advance

-Vinayak
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look closely at your code again, you're probably making a mistake somewhere, maybe just a typing error.

In your code above, you first call your inner class MydrawPanel with a lower case d, but you call it MyDrawPanel with an upper case D later on.
 
Vinayak patil
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,the error was in the typing as you pointed out.

I did not get a class not found error as there was another class MyDrawPanel in the same folder as this file.

Thanks a lot


-Vinayak
 
reply
    Bookmark Topic Watch Topic
  • New Topic