- This topic has 5 replies, 2 voices, and was last updated 18 years, 2 months ago by
Riyad Kalla.
-
AuthorPosts
-
douglasvMemberIn the “New Java Class” dialog
in the section “Which stub would you like to create” I always check “Constructors for Super Class’
and myeclipse Always “NEVER” creates the “Super Class Constructor” , why then the need for a check box
for something that doesn’t Work????
Riyad KallaMemberPlease give me details to try and reproduce on my end. For example, which class are you marking as the super class? I will see if I can figure out what is going on.
douglasvMember@support-rkalla wrote:
Please give me details to try and reproduce on my end. For example, which class are you marking as the super class? I will see if I can figure out what is going on.
this all occurs in the new class dialog, super() .class that will be created from is “java.lang.Object
Riyad KallaMemberdouglasv,
I think there may be a misunderstanding, what that feature does is create constructors in your new class that *match* the ones in the super class. The only constructor that Object has is the default no-arg constructor, so there is no constructor to create.Try doing the same thing using JButton as the parent class, the wizard will correctly generate all 5 constructors from the parent JButton class, like this:
public TestButton() { } public TestButton(Icon icon) { super(icon); } public TestButton(String text) { super(text); } public TestButton(Action a) { super(a); } public TestButton(String text, Icon icon) { super(text, icon); }
douglasvMember@support-rkalla wrote:
douglasv,
I think there may be a misunderstanding, what that feature does is create constructors in your new class that *match* the ones in the super class. The only constructor that Object has is the default no-arg constructor, so there is no constructor to create.Try doing the same thing using JButton as the parent class, the wizard will correctly generate all 5 constructors from the parent JButton class, like this:
public TestButton() { } public TestButton(Icon icon) { super(icon); } public TestButton(String text) { super(text); } public TestButton(Action a) { super(a); } public TestButton(String text, Icon icon) { super(text, icon); }
On eclipse I believe you will get :-” super();”- in the default constructor; at least that’s what others get
Riyad KallaMemberIn that use-case super() is an implicit call, whether you type it or not it will be invoked by the VM. Try it, create a base class that in it’s default constructor prints “Hello!” and then in the subclass print out “World” in it’s default constructor. You will get Hello World.
-
AuthorPosts