• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Non-Default Constructor problem

 
celine mcgowan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I wonder if you could help me. I have the following code, which creates a JPanel with a 'Figure of eight' formation of gifs to represent an LED:

When i try to call this from another class, eg:

I get a compilation error: Method not found: Constructor LED( int ).

Obviously there is a constructor LED(int) in the LED class. Why can't other classes see it?

Thanks a million,
Celine
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi celine
I have interested to test your program.
In your situation, the compiler can not find out the constructor in the LED class, but can find out the LED class.
Method not found: Constructor LED( int ).
Cound you test the following that you wrote the constructor which overrides the default one?

If the compiler can not find out this constructor too, then you can remove both of these constructor and let the compiler find out the default one.
I wonder if you can tell me the result after testing the above procedure
Hope to find out some interesting event
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

you do not pass an but an to the Constructor. and there is no Constructor accepting an .
I did not read your code so i dont know which is wrong (wether you need to pass an array or an int) but you need to change one of them...

pascal
 
celine mcgowan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pascal & Siu

Thanks for your help. Sorry Pascal, please ignore the 'main' method in class LED. I am calling constructor new LED( int ) from another class.

Siu, i tried your suggestion & i the default constructor is found. No error message is received. Now i'm really confused!!!

Thanks again,
Celine
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then please show the code where you call it (and remove the main method since ot wont compile with that)

p
 
Hans Achternaam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Celine,

I copied and compiled the code and had no problem with. Including the constructor call from another class.

BTW are you using a Sun SDK ? This shouldn't matter but since you get an error saying LED( int ) and not LED(int) I just wonder. I'm getting the last error when trying to call a constructor which takes an int and the compiler can not find it. Try this in your class: new LED(1) instead of new LED( 1 )
 
celine mcgowan
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hans,
Yeah, i'm using SunONE Studio. Spaces like this would make a difference? Oh no!!! The people in the cattle drive won't like me taking them out!!
Haha! I'll try that now - thank you all very much for your help.

Hi Again Pascal,
Here's the code calling the LED( int ) constructor:


Thanks again,
Celine
 
Hans Achternaam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, spaces should not make a difference.
Your (new posted) code compiles also without a problem here.

Sorry, no idea what the problem is.
[ August 18, 2004: Message edited by: Hans Achternaam ]
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spaces like this would make a difference? Oh no!!!

Give us five words, "We never do that again"
Of course, I seldom do it.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see in your code where you are calling the LED(int) constructor. I see you calling a LEDPanel, but i don't see where that is defined.

i was able to get your code to compile by changing the lines

to
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ar...yes
error message should be: Method not found: Constructor LEDPanel( int ).
Or
class not found: LEDPanel
[ August 18, 2004: Message edited by: siu chung man ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic