The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Error in calling JFrame's super.

Hi, I'm new here, and I'm trying to learn how to properly use JFrame and some other graphical coding using Java. My problem right now is that my book suggested a code that keep giving me an error when compiling. The error I get from the code below says "call to super must be first statement in constructor.", yet I don't see what I did wrong. Would you all be kind enough to help me solve this please?

Re: Error in calling JFrame's super.

The message "call to super must be first statement in constructor" means what it says: you can only call super() as the first line of a constructor. But you have "super("JFrameDemo");" as the first line of a method. I know it's a method (and so does the compiler) because it returns void, and has a name that is not the same as that of the class.

Re: Error in calling JFrame's super.

-_- Thank you very much. I feel stupid now, lol. I fixed my coding so that it was the same name as the class, and changed the line in the main method and it worked. Thank you for helping me solve that, I don't think I'll forget about this now.