| 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
Bartender
Joined: Aug 16, 2005
Posts: 12911
|
|
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
|
 |
 |
|
|
subject: Error in using Inner classes
|
|
|