aspose file tools*
The moose likes Beginning Java and the fly likes Error in using Inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in using Inner classes" Watch "Error in using Inner classes" New topic
Author

Error in using Inner classes

Vinayak patil
Ranch Hand

Joined: Aug 30, 2005
Posts: 67
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


"I can resist everything except temptation"
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Vinayak patil
Ranch Hand

Joined: Aug 30, 2005
Posts: 67
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in using Inner classes
 
Similar Threads
How LOLbad is this stylistically?
MiniMusicPlayer HFJ
Java Class hangs after run
HFJ Music Box Page 392
Head First Java problem