I’m wondering what the actual reason is why you can do this on a JFrame:
super("My Frame");
And it’s the same as:
setTitle("My Frame");
I understand they are doing the same thing, but what is actually going on with each? Why would you call the super class instead of simply using the inherited methods?
The
JFramehas a constructor that saysIf you follow it, you eventually reach the
java.awt.Frameclass where in its constructor it says:Whose init method does:
Bottom line, you use super, simply because you are invoking that specific constructor. If you use any of the other
JFrameconstructors that won’t receive the given string, then you can set the title manually as you suggest.